4

我是 OSGI 的初学者。我按照以下教程在 eclipse 中做了一个简单的 Hello World OSGI Bundle。 http://www.javaworld.com/javaworld/jw-03-2008/jw-03-osgi1.html?page=2

在运行项目时,我在控制台中收到一堆错误。以下是这些错误:

osgi> !SESSION 2013-07-10 23:23:03.340 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.7.0_07
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments:  -dev file:C:/Users/student/workspace/.metadata/.plugins/org.eclipse.pde.core/OSGi Framework/dev.properties -os win32 -ws win32 -arch x86 -consoleLog -console

!ENTRY org.eclipse.debug.ui 4 0 2013-07-10 23:23:08.809
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Exception in org.eclipse.debug.internal.ui.DebugUIPlugin.start() of bundle org.eclipse.debug.ui.
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
    at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1177)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Caused by: java.lang.IllegalStateException: Workbench has not been created yet.
    at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
    at org.eclipse.debug.internal.ui.contextlaunching.LaunchingResourceManager.startup(LaunchingResourceManager.java:546)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.getLaunchingResourceManager(DebugUIPlugin.java:357)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.start(DebugUIPlugin.java:569)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
    ... 12 more
Root exception:
java.lang.IllegalStateException: Workbench has not been created yet.
    at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
    at org.eclipse.debug.internal.ui.contextlaunching.LaunchingResourceManager.startup(LaunchingResourceManager.java:546)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.getLaunchingResourceManager(DebugUIPlugin.java:357)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.start(DebugUIPlugin.java:569)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
    at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1177)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)

!ENTRY org.eclipse.equinox.p2.core 4 0 2013-07-10 23:23:10.114
!MESSAGE Provisioning exception
!STACK 1
and other similar errors....

你能帮我解决这个问题吗?谢谢你。

4

5 回答 5

8
于 2014-01-28T12:17:18.057 回答
6

我迟到了,但我在尝试使用 eclipse 4.2 从 javaworld 教程创建 Hello World 时遇到了完全相同的问题。

当我取消选择目标平台中的所有捆绑包并按下“添加所需捆绑包”时,eclipse 只选择了

org.eclipse.osgi

运行后,我得到了错误

org.osgi.framework.BundleException: Could not find bundle: org.eclipse.equinox.console

添加控制台并按“添加所需的捆绑包”添加

javax.servlet
org.apache.felix.gogo.runtime
org.eclipse.osgi.services

连同 org.eclipse.osgi

运行此配置导致

org.osgi.framework.BundleException: Missing required bundle: org.apache.felix.gogo.shell

最后,添加

org.apache.felix.gogo.shell

得到了我的期望。

Hello World!!
osgi> ss
"Framework is launched."


id  State       Bundle
0   ACTIVE      org.eclipse.osgi_3.9.0.v20130529-1710
1   ACTIVE      com.javaworld.sample.HelloWorld_1.0.0.qualifier
8   ACTIVE      org.apache.felix.gogo.runtime_0.10.0.v201209301036
9   ACTIVE      org.eclipse.equinox.console_1.0.100.v20130429-0953
10  ACTIVE      javax.servlet_3.0.0.v201112011016
11  ACTIVE      org.eclipse.osgi.services_3.3.100.v20130513-1956
12  ACTIVE      org.apache.felix.gogo.shell_0.10.0.v201212101605
osgi> 
于 2014-01-06T21:37:02.187 回答
1

当您从目标平台启动一些不必要的捆绑包时,会发生该错误。所以只选择所需的捆绑包。

简单地说,在设置运行配置时,请按照以下步骤操作:

  1. 在“捆绑包”选项卡中,先按取消全选。这将从您的工作区以及目标平台中取消选择所有捆绑包。
  2. 现在,在同一选项卡中,从工作区树结构中,选择您自己创建的包。在此之后按“添加所需的捆绑包”。这将从目标平台添加所需的捆绑包。您还可以通过按“验证捆绑包”来验证是否满足所有依赖项。
  3. 现在保存配置并运行。您的捆绑包将被启动,所有其他令人不安的捆绑包将被跳过。
于 2013-07-13T05:28:50.167 回答
0

我有这个完全相同的问题。我设法通过创建一个新的运行配置并取消选择所有捆绑包、添加我的捆绑包然后单击添加所需捆绑包来运行我的捆绑包。

我不知道为什么第二次运行配置有效而第一次无效,我查看了两个 .launch 文件,它们是相同的。

似乎正在发生的事情是一个运行配置正在运行所有可用的包,即使在 gui 中只选择了三个。如果你在所有错误都完成后在 osgi 控制台中输入 ss 命令,我会为损坏的启动配置启动 1182 个捆绑包,而工作配置只给我正确的 3。

您应该尝试创建一个新的启动配置并查看是否对其进行排序,我不知道为什么新配置对我有用,但确实如此,希望这会有所帮助。

工作配置 ss 的输出:

id      State       Bundle
0       ACTIVE      org.eclipse.osgi_3.7.2.dist
                    Fragments=1
1       RESOLVED    javax.transaction_1.1.1.v201105210645
                    Master=0
2       ACTIVE      com.javaworld.sample.HelloWorld_1.0.0.qualifier

最后几行损坏的配置 ss:

1040    ACTIVE      org.sonatype.m2e.mavenarchiver_0.15.0.201212080009
1041    ACTIVE      org.testng.eclipse_6.8.0.20121120_1820
1042    ACTIVE      org.uddi4j_2.0.5.v200805270300
1043    ACTIVE      org.w3c.css.sac_1.3.0.v200805290154
1044    ACTIVE      org.w3c.dom.smil_1.0.0.v200806040011
1045    ACTIVE      org.w3c.dom.svg_1.1.0.v201011041433
1046    ACTIVE      org.w3c.sac_1.3.0.v20120213
1155    <<LAZY>>    org.eclipse.equinox.simpleconfigurator_1.0.200.dist
1182    <<LAZY>>    org.eclipse.equinox.initializer_1.0.0.dist
于 2013-07-23T08:21:28.660 回答
0

设置 android:targetSdkVersion="19 为我解决了这个问题。

于 2015-02-18T12:12:15.927 回答