问题
I'm trying to execute my RCP application I recently moved from eclipse Indigo to Photon. After changing/updating the required libraries, I have managed to run the application without problems launching the product as an Eclipse application (from the Eclipse IDE).
However, when I export the product to a native executable and launch it, I get several InjectionException
!SESSION 2018-09-06 16:48:55.406 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_171
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=es_ES
Framework arguments: -clearPersistedState
Command-line arguments: -os win32 -ws win32 -arch x86 -clean -clearPersistedState
!ENTRY org.eclipse.e4.ui.workbench 4 0 2018-09-06 16:48:59.412
!MESSAGE Unable to create class 'org.eclipse.e4.ui.internal.workbench.addons.CommandProcessingAddon' from bundle '52'
!STACK 0
org.eclipse.e4.core.di.InjectionException: Unable to process "CommandProcessingAddon.broker": no actual value was found for the argument "IEventBroker".
at org.eclipse.e4.core.internal.di.InjectorImpl.reportUnresolvedArgument(InjectorImpl.java:489)
at org.eclipse.e4.core.internal.di.InjectorImpl.resolveRequestorArgs(InjectorImpl.java:480)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalInject(InjectorImpl.java:126)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:412)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:345)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:214)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:108)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:74)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:51)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:282)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:617)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:597)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
...
!ENTRY org.eclipse.e4.ui.workbench 4 0 2018-09-06 16:48:59.419
!MESSAGE Unable to create class 'org.eclipse.e4.ui.internal.workbench.addons.ContextProcessingAddon' from bundle '52'
!STACK 0
org.eclipse.e4.core.di.InjectionException: Unable to process "ContextProcessingAddon.broker": no actual value was found for the argument "IEventBroker".
at org.eclipse.e4.core.internal.di.InjectorImpl.reportUnresolvedArgument(InjectorImpl.java:489)
at org.eclipse.e4.core.internal.di.InjectorImpl.resolveRequestorArgs(InjectorImpl.java:480)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalInject(InjectorImpl.java:126)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:412)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:345)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:214)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:108)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:74)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:51)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:282)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:617)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:597)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
etc.
I have checked that the plugin list on the launch configuration and the product are the same (selected with "add required plugins" and checked with "validate plugins" on the launch configuration). In fact, pressing the add required plugins from the product page seems to leave some plugins out that the launch window includes (and seem to be needed in order to the application to launch in within eclipse) so I've added the missing plugins by hand to the product, but still no luck. I have uploaded the final plugin list (the one from the launch configuration) to this pastebin to see if it somewhat related to it. The plugin list automatically generated from the product is virtually the same but contains 7 plugins less (and I added then as I said above).
I'm new to Eclipse Photon and all this injection mechanism, but I'm pretty sure my project doesn't use it directly (maybe some new plugin that is included uses it indirectly?).
I have used the -clean and -cleanPersistedState parameters as suggested in another answer to deal with the injection problems but I still get same results.
Any clues on how to solve this or how to disable injection/which plugin is causing the injection to be called?
Regards
回答1:
Probably the OSGi declarative services plugin org.eclipse.equinox.ds
is not being started which would prevent the event broker factory from running.
If you are using an xxx.product file to configure the RCP check the 'Start Levels' section of the 'Configuration' tab. Use the 'Add Recommended' button to add the recommended start configuration which includes org.eclipse.equinox.ds
Update: For Eclipse 2018-09 onwards org.apache.felix.scr
replaces org.eclipse.equinox.ds
and requires similar start level configuration.
来源:https://stackoverflow.com/questions/52207542/rcp-application-run-from-eclipse-runs-fine-exporting-it-throws-injectionexcepti