OSGi Bundle helloworld所遇到问题

本文详细介绍了在使用Eclipse运行OSGi Bundle的HelloWorld示例时遇到的问题,包括如何解决缺少控制台包和依赖冲突导致的错误,并通过引入额外的依赖包成功解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

OSGi Bundle之Hello World

http://developer.51cto.com/art/200909/152209.htm


按照这篇文章介绍的helloworld在eclipse上跑osgi发现报错,去掉配置项的-console后可以跑起helloworld

但是肯定是需要这个控制台的,带上控制台发现报错如下:


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

at org.eclipse.osgi.framework.internal.core.ConsoleManager.checkForConsoleBundle(ConsoleManager.java:211)

at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:297)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:601)

at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)

at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)

at org.eclipse.equinox.launcher.Main.run(Main.java:1438)

at org.eclipse.equinox.launcher.Main.main(Main.java:1414)


经测试需要引入org.eclipse.equinox.console包,再次运行又报错:


org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.console_1.0.0.v20120522-1841 [11]" could not be resolved. Reason: Missing Constraint: Import-Package: org.apache.felix.service.command; version="0.8.0"

at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1332)

at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1316)

at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:323)

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.osgi 4 0 2013-05-19 00:43:53.968

!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.equinox.console_1.0.0.v20120522-1841.jar was not resolved.


!ENTRY org.eclipse.osgi 4 0 2013-05-19 00:43:53.972

!MESSAGE Could not start bundle: org.eclipse.equinox.console

!STACK 0

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

at org.eclipse.osgi.framework.internal.core.ConsoleManager.checkForConsoleBundle(ConsoleManager.java:217)

at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:297)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:601)

at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)

at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)

at org.eclipse.equinox.launcher.Main.run(Main.java:1438)

at org.eclipse.equinox.launcher.Main.main(Main.java:1414)

Caused by: org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.console_1.0.0.v20120522-1841 [11]" could not be resolved. Reason: Missing Constraint: Import-Package: org.apache.felix.service.command; version="0.8.0"

at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1332)

at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1316)

at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:323)

at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)

at org.eclipse.osgi.framework.internal.core.ConsoleManager.checkForConsoleBundle(ConsoleManager.java:215)

... 10 more

Root exception:

org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.console_1.0.0.v20120522-1841 [11]" could not be resolved. Reason: Missing Constraint: Import-Package: org.apache.felix.service.command; version="0.8.0"

at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1332)

at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1316)

at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:323)

at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)

at org.eclipse.osgi.framework.internal.core.ConsoleManager.checkForConsoleBundle(ConsoleManager.java:215)

at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:297)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:601)

at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)

at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)

at org.eclipse.equinox.launcher.Main.run(Main.java:1438)

at org.eclipse.equinox.launcher.Main.main(Main.java:1414)


这时需要引入

org.apache.felix.gogo.command
org.apache.felix.gogo.runtime

org.apache.felix.gogo.shell

问题解决!


评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值