eclipse: 启动插件项目后出现异常

eclipse: Exceptions after I start a plug-in project

我尝试了该教程:Hello, OSGi, Part 1: Bundles for beginners,开始后我得到了 Hello World!消息,还有很多例外情况:

org.osgi.framework.BundleException: Exception in org.eclipse.datatools.enablement.oda.ws.ui.Activator.start() of bundle org.eclipse.datatools.enablement.oda.ws.ui.
    at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:792)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:721)
    at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:941)
    at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:318)
    at org.eclipse.osgi.container.Module.doStart(Module.java:571)
    at org.eclipse.osgi.container.Module.start(Module.java:439)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1582)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1562)
....
Root exception:
org.eclipse.swt.SWTError: Invalid thread access
    at org.eclipse.ui.plugin.AbstractUIPlugin.createImageRegistry(AbstractUIPlugin.java:217)
    at org.eclipse.ui.plugin.AbstractUIPlugin.getImageRegistry(AbstractUIPlugin.java:261)
    at org.eclipse.datatools.enablement.oda.ws.ui.Activator.declareImage(Activator.java:82)
    at org.eclipse.datatools.enablement.oda.ws.ui.Activator.declareImage(Activator.java:77)
    at org.eclipse.datatools.enablement.oda.ws.ui.Activator.declareImages(Activator.java:59)
    at org.eclipse.datatools.enablement.oda.ws.ui.Activator.start(Activator.java:54)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.run(BundleContextImpl.java:771)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.run(BundleContextImpl.java:1)
    at java.security.AccessController.doPrivileged(Native Method)
...
java.lang.IllegalStateException: Workbench has not been created yet.
    at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:93)
    at org.eclipse.debug.internal.ui.DebugUIPreferenceInitializer.setThemeBasedPreferences(DebugUIPreferenceInitializer.java:208)
    at org.eclipse.debug.internal.ui.DebugUIPreferenceInitializer.initializeDefaultPreferences(DebugUIPreferenceInitializer.java:81)
    at org.eclipse.core.internal.preferences.PreferenceServiceRegistryHelper.run(PreferenceServiceRegistryHelper.java:300)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)

还有更多。有什么想法吗?

我正在 linux 上与 Mars.1 合作。


我试图取消选中不必要的包(仍然是 org.apache.felix.gogo.runtimeorg.apache.felix.gogo.shell, org.eclipse.equinox.console, org.eclipse.osgi), 然后我收到这样的消息:

!ENTRY org.eclipse.update.configurator 4 0 2015-11-24 22:20:46.988
!MESSAGE Could not install bundle plugins/org.eclipse.equinox.p2.repository_2.3.100.v20150428-1613.jar   A bundle is already installed with the name "org.eclipse.equinox.p2.repository" and version "2.3.100.v20150428-1613"

!ENTRY org.eclipse.update.configurator 4 0 2015-11-24 22:20:46.995
!MESSAGE Could not install bundle plugins/org.eclipse.datatools.enablement.oracle.ui_1.0.3.v201201131121.jar   A bundle is already installed with the name "org.eclipse.datatools.enablement.oracle.ui" and version "1.0.3.v201201131121"

!ENTRY org.eclipse.update.configurator 4 0 2015-11-24 22:20:46.998
!MESSAGE Could not install bundle plugins/org.eclipse.wst.jsdt.support.firefox_1.0.500.v201402051800.jar   A bundle is already installed with the name "org.eclipse.wst.jsdt.support.firefox" and version "1.0.500.v201402051800"

但在那之后同样的例外

您的捆绑包激活出现问题。您显示的所有错误都是捆绑包,假设它们是 运行 一个 Workbench 或 SWT UI 线程。对于纯 OSGi 运行,这些都不是必需的。

在您的启动配置中,检查您是否没有将不需要的包启用为您的第一个调用端口。例如在 "Bundles" 选项卡中取消选中除示例插件和 OSGi 包之外的所有内容 org.eclipse.osgi.

特别是 org.eclipse.ui 捆绑包和您不想要的类似捆绑包。

此外,确保您使用的是 OSGi 框架 启动配置类型,而不是 Eclipse 应用程序

可能为时已晚,但我在 Eclipse Mars.1 上遇到了同样的问题。我必须做的是: 在第一个 运行ning 之前: 运行>运行 配置> 将显示“创建、管理和 运行 配置 window。您必须从左侧列表中选择 OSGi 框架并设置配置: 在工作区检查你的项目, 在目标平台中,您应该只选择:

-org.apache.felix.gogo.command
-org.apache.felix.gogo.runtime
-org.apache.felix.gogo.shell
-org.eclipse.equinox.console
-org.eclipse.osgi

然后取消选中 "Include optional dependencies..." 并选中 "Add new workspace.." 和 "Validate bundles.."

申请并运行。 我不知道为什么,但我尝试先(再尝试几次)运行ning 之后和设置 运行ning conf 之后设置它。无论如何它都没有用,但我试着再做一次,我设置了 运行 配置。在我 运行 第一次使用它之前,它成功了。

无论如何我都建议安装 Eclipse Luna,因为它运行得更好(应该如此)。