我是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....
你能帮我解决这个问题吗?谢谢。
答案 0 :(得分: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>
答案 1 :(得分:6)
我很努力“Workbench还没有创建”整整一天。
但我通过以下步骤获得了解决方案 .-
由于
答案 2 :(得分:1)
从目标平台启动一些不必要的捆绑包时会发生错误。所以只选择所需的包。
简单地说,在设置运行配置时,请按照以下步骤操作:
答案 3 :(得分:0)
我有同样的问题。我设法通过创建新的运行配置并取消选择所有包,添加我的包然后单击Add Required Bundles来运行我的包。
我不知道为什么第二次运行配置有效,而第一次没有,我查看了两个.launch文件,它们完全相同。
似乎正在发生的事情是,一个运行配置正在运行所有可用的捆绑包,即使在gui中只选择了三个。如果在完成所有错误后在osgi控制台中输入ss命令,我会为损坏的启动配置启动1182个捆绑包,其中工作配置只给我正确的3。
您应该尝试创建一个新的启动配置并查看是否对其进行排序,我不知道为什么新的启动配置适用于我,但确实如此,希望这会有所帮助。
工作配置输出:
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
最后几行破坏的配置:
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
答案 4 :(得分:0)
设置android:targetSdkVersion =&#34; 19为我解决了这个问题。