Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see full exception stack trace when running java app from console?

While running java app from console i got an exception, that contains following line:

... 5 more

Is it possible to see a full trace? Is there any cmd argument?

Thanks.

like image 929
johnny-b-goode Avatar asked Oct 12 '12 14:10

johnny-b-goode


1 Answers

The full trace is there, but it is a repeat of the nested exception above which is why it is summarised.

public class Main {
    public static void throwsException() {
        throw new UnsupportedOperationException();
    }

    public static void main(String... args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        Main.class.getMethod("throwsException").invoke(null);
    }
}

prints

Exception in thread "main" java.lang.reflect.InvocationTargetException
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:601)
     at Main.main(Main.java:27)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:601)
     at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.UnsupportedOperationException
     at Main.throwsException(Main.java:23)
     ... 10 more

The ... 10 more means it is a repeat of the stack trace of the exception which wraps it.

like image 156
Peter Lawrey Avatar answered Oct 21 '22 17:10

Peter Lawrey