版权声明:本文为博主原创文章,未经博主同意不得转载。 https://blog.csdn.net/canlets/article/details/29620301

今天学习OSGI的过程中依照书上所述搭建好第一个helloworld插件project。执行的过程中出现以下所看到的的错误:

!SESSION 2014-06-09 21:04:49.038 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_35
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Command-line arguments: -dev file:E:/XJTU/.metadata/.plugins/org.eclipse.pde.core/Hello OSGI/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog -console !ENTRY org.eclipse.osgi 4 0 2014-06-09 21:04:49.616
!MESSAGE Could not find bundle: org.eclipse.equinox.console
!STACK 0
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:298)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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)

于是乎上网google发现须要同一时候引入org.eclipse.equinox.console这个bundle。赶紧照做,例如以下图所看到的

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY3J1aXNlX2g=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="" />

原以为就此能够大功告成,不料...,看下文(等待我的是很多其它的Exception)

!SESSION 2014-06-09 21:09:17.097 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_35
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Command-line arguments: -dev file:E:/XJTU/.metadata/.plugins/org.eclipse.pde.core/Hello OSGI/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog -console !ENTRY org.eclipse.equinox.console 4 0 2014-06-09 21:09:17.725
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.console_1.0.100.v20130429-0953 [6]" 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 2014-06-09 21:09:17.725
!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 2014-06-09 21:09:17.725
!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(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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 [6]" 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 [6]" 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(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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 2014-06-09 21:09:17.735
!MESSAGE One or more bundles are not resolved because the following root constraints are not resolved:
!SUBENTRY 1 org.eclipse.osgi 2 0 2014-06-09 21:09:17.735
!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 2014-06-09 21:09:17.735
!MESSAGE Missing imported package org.apache.felix.service.command_0.8.0. !ENTRY org.eclipse.osgi 2 0 2014-06-09 21:09:17.745
!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 2014-06-09 21:09:17.745
!MESSAGE Bundle org.eclipse.equinox.console_1.0.100.v20130429-0953 [6] was not resolved.
!SUBENTRY 2 org.eclipse.equinox.console 2 0 2014-06-09 21:09:17.745
!MESSAGE Missing imported package org.apache.felix.service.command_0.8.0.
!SUBENTRY 2 org.eclipse.equinox.console 2 0 2014-06-09 21:09:17.745
!MESSAGE Missing optionally imported package org.osgi.service.cm_0.0.0.

实在是郁闷的慌,于是乎又開始各种search...

最终找到了终极解决方式。即再次增加三个org.eclipse.equinox.console必须的依赖bundle,各自是:

org.apache.felix.gogo.command

org.apache.felix.gogo.runtime

org.apache.felix.gogo.shell

概括一下:当Run时报错,仅仅选种org.eclipse.equinox.console时还是会报错,那时由于OSGI组建之间存在依赖关系,要使用 org.eclipse.equinox.console必须要有它须要依赖的OSGI组建,因此在调试时,除了选择自己编写的OSGI组建还要选择上面的三个bundle。貌似这个问题在之前的Eclipse版本号中没有滴,预计是进一步的重构之后的缘故。

总之。依照这样的方式就能够顺利的Run了。

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY3J1aXNlX2g=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="" />

在osgi>提示符输入ss命令。能够看到例如以下的详情:

能够看到HelloWorld bundle已经被安装而且解析完毕,可是还没有启动(这是由于我设置的是不自己主动start);

在osgi>提示符后面输入start 1。然后再次ss,会发现helloworld bundle已经启动(ACTIVE)。

最新文章

  1. problem-eclipse创建maven项目报错
  2. selenium之操作ChromeDriver
  3. linux 安装
  4. 使用Modernizr探测HTML5/CSS3新特性
  5. How to changes to Table & EDT Relations[AX2012]
  6. ViewPager的基本使用--可左右循环切换也可自动切换
  7. PHP 关于 $GLOBALS['HTTP_RAW_POST_DATA']
  8. Git 2.7: 一个新的带来许多新特性和性能提升的主要版本
  9. asp.net根据模版生成Word小记
  10. Angular - - $rootScope.Scope
  11. cookie和session的区别异同
  12. 鹅场offer已Get,下周签约,终于能静下心来总结总结
  13. 【算法】Attention is all you need
  14. MySQL/Oracle索引的创建与使用
  15. flask中接收post传递数组方法
  16. Linux下防御DDOS攻击的操作梳理
  17. I - Interesting Calculator (bfs使用优先队列求步数最小或者花费最小)
  18. 第一个Sprint冲刺总结(事后诸葛亮及团队贡献分)
  19. BZOJ2460 Beijing2011元素(线性基+贪心)
  20. e868. 获取和设置本地外观

热门文章

  1. tuple&dict
  2. AOP拦截日志类,抛异常:java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode
  3. 【串线篇】spring boot页面模板引擎
  4. linux运维、架构之路-正则表达式
  5. php怎么启动exe文件
  6. 【Go】Go语言的%d,%p,%v等占位符的使用
  7. Nginx的启动、停止与重启---linux
  8. 【HDOJ6629】string matching(exkmp)
  9. 31 October
  10. EZOJ #373排序