您的位置:首页 > 其它

OSGi进阶环境配置遇到问题,我的解决方案

2015-02-11 15:53 134 查看
OSGi实战看完了,感觉作者写的很好,接着看OSGi进阶这篇Opendoc,首先是搭建环境,在OSGi实战中的环境搭建,我按着作者的方法搭建出来有问题,通过网上一系列搜寻找到了解决方案,如果大家在OSGi实战环境搭建也遇到问题,可以查看这篇博客点击打开链接

好了接下来看看我在OSGi进阶中遇到的问题吧

按着作者的说明,我引入了下图所示的几个bundle



点击运行就发现这样的错误

!SESSION 2015-02-11 15:41:49.097 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_25
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=zh_CN
Command-line arguments:  -dev file:D:/OSGi/bulletin/.metadata/.plugins/org.eclipse.pde.core/samplebulletin/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog -console

!ENTRY org.eclipse.equinox.ds 4 0 2015-02-11 15:41:51.318
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.ds_1.4.101.v20130813-1853 [5]" could not be resolved. Reason: Missing Constraint: Import-Package: org.eclipse.equinox.internal.util.event; version="1.0.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:1176)
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.console 4 0 2015-02-11 15:41:52.006
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.console_1.0.100.v20130429-0953 [9]" 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:1176)
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 2015-02-11 15:41:52.021
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.equinox.ds_1.4.101.v20130813-1853.jar was not resolved.

!ENTRY org.eclipse.osgi 4 0 2015-02-11 15:41:52.021
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.equinox.console_1.0.100.v20130429-0953.jar was not resolved.

!ENTRY org.eclipse.osgi 4 0 2015-02-11 15:41:52.021
!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:298)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.console_1.0.100.v20130429-0953 [9]" 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.100.v20130429-0953 [9]" 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:298)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)

!ENTRY org.eclipse.osgi 2 0 2015-02-11 15:41:52.099
!MESSAGE One or more bundles are not resolved because the following root constraints are not resolved:
!SUBENTRY 1 org.eclipse.osgi 2 0 2015-02-11 15:41:52.099
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.equinox.ds_1.4.101.v20130813-1853.jar was not resolved.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:41:52.099
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.threadpool_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:41:52.099
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.event_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:41:52.099
!MESSAGE Missing required capability Require-Capability: osgi.ee; filter="(|(&(osgi.ee=OSGi/Minimum)(version=1.2))(&(osgi.ee=CDC/Foundation)(version=1.1))(&(osgi.ee=JavaSE)(version=1.4)))".
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:41:52.099
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.pool_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:41:52.099
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.ref_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:41:52.099
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.hash_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:41:52.115
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.timer_1.0.0.
!SUBENTRY 1 org.eclipse.osgi 2 0 2015-02-11 15:41:52.115
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.equinox.console_1.0.100.v20130429-0953.jar was not resolved.
!SUBENTRY 2 org.eclipse.equinox.console 2 0 2015-02-11 15:41:52.115
!MESSAGE Missing imported package org.apache.felix.service.command_0.8.0.

!ENTRY org.eclipse.osgi 2 0 2015-02-11 15:41:52.224
!MESSAGE The following is a complete list of bundles which are not resolved, see the prior log entry for the root cause if it exists:
!SUBENTRY 1 org.eclipse.osgi 2 0 2015-02-11 15:41:52.224
!MESSAGE Bundle org.eclipse.equinox.ds_1.4.101.v20130813-1853 [5] was not resolved.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:41:52.224
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.event_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:41:52.224
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.hash_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:41:52.240
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.pool_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:41:52.240
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.ref_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:41:52.256
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.threadpool_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:41:52.256
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.timer_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:41:52.256
!MESSAGE Missing imported package org.apache.felix.scr_[1.6.0,1.7.0).
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:41:52.256
!MESSAGE Missing required capability Require-Capability: osgi.ee; filter="(|(&(osgi.ee=OSGi/Minimum)(version=1.2))(&(osgi.ee=CDC/Foundation)(version=1.1))(&(osgi.ee=JavaSE)(version=1.4)))".
!SUBENTRY 1 org.eclipse.osgi 2 0 2015-02-11 15:41:52.256
!MESSAGE Bundle org.eclipse.equinox.console_1.0.100.v20130429-0953 [9] was not resolved.
!SUBENTRY 2 org.eclipse.equinox.console 2 0 2015-02-11 15:41:52.256
!MESSAGE Missing imported package org.apache.felix.service.command_0.8.0.


看过文章上面的推荐另一篇博客的童鞋可能就知道,看到第二个错误提示
org.apache.felix.service.command


提示少引入了这个包,可以查看那篇博客,点击打开链接寻找答案

为了节省大家时间,就直接告诉大家了,其实就是再引入这三个包就可以了



再次点击运行(别忘了把之前运行错误的这个程序关闭,不然会出现端口号被占用的错误)

会出现这个错误:

!SESSION 2015-02-11 15:47:48.548 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_25
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=zh_CN
Command-line arguments:  -dev file:D:/OSGi/bulletin/.metadata/.plugins/org.eclipse.pde.core/samplebulletin/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog -console

!ENTRY org.eclipse.equinox.ds 4 0 2015-02-11 15:47:50.344
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.ds_1.4.101.v20130813-1853 [5]" could not be resolved. Reason: Missing Constraint: Import-Package: org.eclipse.equinox.internal.util.event; version="1.0.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:1176)
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 2015-02-11 15:47:50.937
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.equinox.ds_1.4.101.v20130813-1853.jar was not resolved.

!ENTRY org.eclipse.osgi 2 0 2015-02-11 15:47:50.969
!MESSAGE One or more bundles are not resolved because the following root constraints are not resolved:
!SUBENTRY 1 org.eclipse.osgi 2 0 2015-02-11 15:47:50.984
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.equinox.ds_1.4.101.v20130813-1853.jar was not resolved.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:47:50.984
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.timer_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:47:50.984
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.event_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:47:50.984
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.hash_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:47:50.984
!MESSAGE Missing required capability Require-Capability: osgi.ee; filter="(|(&(osgi.ee=OSGi/Minimum)(version=1.2))(&(osgi.ee=CDC/Foundation)(version=1.1))(&(osgi.ee=JavaSE)(version=1.4)))".
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:47:50.984
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.threadpool_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:47:50.984
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.ref_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:47:51.000
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.pool_1.0.0.

!ENTRY org.eclipse.osgi 2 0 2015-02-11 15:47:51.015
!MESSAGE The following is a complete list of bundles which are not resolved, see the prior log entry for the root cause if it exists:
!SUBENTRY 1 org.eclipse.osgi 2 0 2015-02-11 15:47:51.015
!MESSAGE Bundle org.eclipse.equinox.ds_1.4.101.v20130813-1853 [5] was not resolved.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:47:51.015
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.event_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:47:51.015
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.hash_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:47:51.015
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.pool_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:47:51.031
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.ref_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:47:51.031
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.threadpool_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:47:51.031
!MESSAGE Missing imported package org.eclipse.equinox.internal.util.timer_1.0.0.
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:47:51.047
!MESSAGE Missing imported package org.apache.felix.scr_[1.6.0,1.7.0).
!SUBENTRY 2 org.eclipse.equinox.ds 2 0 2015-02-11 15:47:51.047
!MESSAGE Missing required capability Require-Capability: osgi.ee; filter="(|(&(osgi.ee=OSGi/Minimum)(version=1.2))(&(osgi.ee=CDC/Foundation)(version=1.1))(&(osgi.ee=JavaSE)(version=1.4)))".
osgi>
系统提示缺少这个包

org.eclipse.equinox.internal.util.event
可以当你试图引入这个包的时候发现根本没有这个bundle,这时,你需要引入的是



如果再次运行,是不是发现成功了,输入ss看一下现在运行的都有哪些bundle



至此这个环境就算是搭建好了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: