Community
Participate
Working Groups
When logging InvocationTargetExceptions, the nested exception, which contains the real cause of the problem, is often omitted. One approach is to always log the innermost exception (even with multiple levels of nesting). Another is to ensure that every frame for every exception in the chain is printed.
One example is: bug 44735.
Does this mean that we should be changing code in the platform logger when logging invocation target exceptions?
We already do something like that for BundleExceptions (see DefaultLog#getStackTrace). We could easily do the same for InvocationTargetExceptions. The (minor) problem with doing this is that nested exceptions may appear twice in the log entry (once as generated by Throwable.printStackTrace, as in the bug mentioned above, and again, written by us). The other approach mentioned in the original report does not work with Java 1.3/eeminimum (programmatic access to stack trace frames was added in 1.4). I guess this should be moved to Equinox.
The resolution of this depends on bug 60267.
Fixed. Released to HEAD. We will ensure the deepest exception is always logged (will skip BundleExceptions/InvocationTargetExceptions). Example: !ENTRY reference:file:d:/target/releasing/plugins/org.eclipse.core.runtime/ 0 0 Apr 28, 2004 12:23:39.40 !MESSAGE FrameworkEvent.ERROR !STACK 0 org.osgi.framework.BundleException: Exception in org.eclipse.core.internal.runtime.PlatformActivator.start() of bundle org.eclipse.core.runtime. at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:990) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:952) at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:408) at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:373) at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:999) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:571) at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:482) at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:272) at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:442) at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:153) at org.eclipse.osgi.framework.eventmgr.EventThread$Queued.dispatchEvent(EventThread.java:56) at org.eclipse.osgi.framework.eventmgr.EventThread.run(EventThread.java:107) Caused by: org.osgi.framework.BundleException: nested 1 at org.eclipse.core.internal.runtime.PlatformActivator.start(PlatformActivator.java:55) at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:973) at java.security.AccessController.doPrivileged(Native Method) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:969) ... 11 more Caused by: java.lang.reflect.InvocationTargetException: nested 2 ... 15 more Caused by: java.lang.RuntimeException: nested 3 ... 15 more Root exception: java.lang.RuntimeException: nested 3 at org.eclipse.core.internal.runtime.PlatformActivator.start(PlatformActivator.java:55) at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:973) at java.security.AccessController.doPrivileged(Native Method) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:969) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:952) at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:408) at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:373) at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:999) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:571) at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:482) at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:272) at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:442) at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:153) at org.eclipse.osgi.framework.eventmgr.EventThread$Queued.dispatchEvent(EventThread.java:56) at org.eclipse.osgi.framework.eventmgr.EventThread.run(EventThread.java:107) The "Caused by" stacks are written by Throwable#printStackTrace on Sun/IBM JDK 1.4.*. We write the "Root exception" after that, which is usually the most important one.