views:

52

answers:

2

Hi all,

I meet a weired problem when I use maven. I execute the following code using "maven exec:java". Obviously, it should throw a RuntimeException, but I did not see anything in console. But if I execute it in eclipse, I can see the error message. So where does the exception gone ? Thanks

public class HelloWorld {

    public static class MyThread extends Thread {

        @Override
        public void run() {
            String str = null;
            str = str.trim();
        }
    }

    public static void main(String[] args) throws InterruptedException, IOException {
        MyThread thread = new MyThread();
        thread.start();
        System.in.read();
    }
}
+3  A: 

Might be a bug of the Maven Exec Plugin (see issues like MEXEC-89 or MEXEC-80). Try with the version 1.2 of the plugin:

mvn org.codehaus.mojo:exec-maven-plugin:1.2:java -Dexec.mainClass="com.acme.Foo"
Pascal Thivent
A: 

You could also try adding the -e command line option to your mvn call, I think that solved a similar problem I had.

Jörn Horstmann