2

I am working on a Eclipse E4 RCP application and I use Dependency Injection.

I have noticed that when there is a runtime exception in the postconstruct, then I don't see that Exception in the console (is it swallowed?). I do see an exception that that class can't be injected.

So for example the following code:

@Creatable
@Singleton
public class OurClass {
    @PostConstruct
    public void postConstruct() {
        System.out.println("PostConstruct Start");
        throw new RuntimeException("Test");
    }
}

public class OurPart {
    @Inject
    private OurClass ourClass;
}

Gives the following output:

PostConstruct Start
org.eclipse.e4.core.di.InjectionException: Unable to process "OurPart.ourClass": no actual value was found for the argument "OurClass".
    at org.eclipse.e4.core.internal.di.InjectorImpl.reportUnresolvedArgument(InjectorImpl.java:392)
    at org.eclipse.e4.core.internal.di.InjectorImpl.resolveRequestorArgs(InjectorImpl.java:383)
    at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:100)
    at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:318)
    at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:240)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:161)
    at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:102)
    at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:71)
    at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:53)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.processHierarchy(E4Workbench.java:170)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.init(E4Workbench.java:118)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.<init>(E4Workbench.java:69)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:302)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:132)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.equinox.internal.app.MainApplicationLauncher.run(MainApplicationLauncher.java:32)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
PostConstruct Start

Does anyone know how to make sure the runtime exception is also shown?

Renso Lohuis
  • 484
  • 4
  • 8

0 Answers0