从Eclipse运行的RCP应用程序运行良好,将其导出会抛出InjectionExceptions

时间:2018-09-06 15:28:40

标签: java eclipse rcp eclipse-photon

我正在尝试执行我最近从Eclipse Indigo转到Photon的RCP应用程序。更改/更新了所需的库之后,我已经成功地运行了该应用程序,而没有将产品作为Eclipse应用程序(从Eclipse IDE)启动的问题。

但是,当我将产品导出到本机可执行文件并启动它时,会出现几个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)

我检查了启动配置和产品上的插件列表是否相同(使用“添加必需的插件”进行选择,并在启动配置中使用“验证插件”进行了检查)。实际上,在产品页面上按添加所需的插件似乎会使启动窗口包含一些插件(似乎是必需的,以便应用程序在eclipse中启动),因此我手动添加了缺少的插件产品,但仍然没有运气。我已经上传了最终的插件列表(启动配置中的那个)to this pastebin,以查看它是否与此相关。从产品自动生成的插件列表实际上是相同的,但是少包含7个插件(如上所述,我添加了这个插件)。

我是Eclipse Photon和所有这种注入机制的新手,但是我可以肯定我的项目不会直接使用它(也许其中包含的某些新插件会间接使用它吗?)。

我使用了另一个答案中建议的-clean和-cleanPersistedState参数来处理注入问题,但是我仍然得到相同的结果。

关于如何解决此问题或如何禁用注入的任何线索/哪个插件导致注入被调用?

致谢

1 个答案:

答案 0 :(得分:8)

可能未启动OSGi声明性服务插件org.eclipse.equinox.ds,这将阻止事件代理工厂运行。

如果您使用xxx.product文件配置RCP,请检查“配置”选项卡的“启动级别”部分。使用“添加推荐的”按钮添加推荐的启动配置,其中包括org.eclipse.equinox.ds

更新:从Eclipse 2018-09开始,org.apache.felix.scr替换了org.eclipse.equinox.ds,并且需要类似的起始级别配置。