今天学习OSGI的过程中按照书上所述搭建好第一个helloworld插件工程,运行的过程中出现下面所示的错误:

!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,赶紧照做,如下图所示;

原以为就此可以大功告成,不料...,看下文(等待我的是更多的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,分别是:

  1. <span style="font-family:Microsoft YaHei;font-size:14px;">  org.apache.felix.gogo.command  org.apache.felix.gogo.runtime  org.apache.felix.gogo.shell</span>

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

在osgi>提示符输入ss命令,可以看到如下的详情:

 
 
另外 :需添加配置参数
 

在Eclipse中运行OSGI工程出错的解决方案的更多相关文章

  1. eclipse中运行出错:无法初始化主类的解决办法

    问题描述:eclipse中运行程序时,出现如下错误 解决办法: 出现此类:无法初始化主类有可能是因为eclipse中Java的版本与JDK的版本不匹配,我开始用的时候eclipse中用的是Java s ...

  2. 在eclipse中运行storm-starter

    开源软件官网提供的demo无疑是学习开源软件的最好的最原始的样例. 在Storm官网里下载apache-storm-0.9.6.zip,里面\examples\storm-starter\src\jv ...

  3. Eclipse中Maven WEB工程tomcat调试

    最近没事了玩一下maven,使用maven管理工程中的依赖包非常的方便.建立maven web工程的时候开始不知道怎么用tomcat来调试,总是使用mave的tomcat插件发布了后来调试,觉得非常的 ...

  4. Nodejs学习笔记(二)——Eclipse中运行调试Nodejs

    前篇<Nodejs学习笔记(一)——初识Nodejs>主要介绍了在搭建node环境过程中遇到的小问题以及搭建Eclipse开发Node环境的前提步骤.本篇主要介绍如何在Eclipse中运行 ...

  5. monkeyrunner之eclipse中运行monkeyrunner脚本之环境搭建(四)

    monkeyrunner脚本使用Python语法编写,但它实际上是通过Jython来解释执行. Jython是Python的Java实现,它将Python代码解释成Java虚拟机上的字节码并执行,这种 ...

  6. 转载Eclipse中Maven WEB工程tomcat项目添加调试

    转载地址: http://blog.csdn.net/free4294/article/details/38260581 一.建立一个maven  WEB项目 1.file->new->o ...

  7. 在Eclipse中运行Web项目Jsp网页时提示端口被占用的解决办法:Several ports (8005, 8888, 8009) required by Tomcat v9.0 Server at localhost are already in use.

    问题: 在Eclipse中运行Web项目Jsp网页启动Tomcat时提示端口被占用: Several ports (8005, 8080, 8009) required by Tomcat v9.0 ...

  8. 在Eclipse中运行JAVA代码远程操作HBase的示例

    在Eclipse中运行JAVA代码远程操作HBase的示例 分类: 大数据 2014-03-04 13:47 3762人阅读 评论(2) 收藏 举报 下面是一个在Windows的Eclipse中通过J ...

  9. 在Eclipse中运行Jboss时出现java.lang.OutOfMemoryError:PermGen space及其解决方法

    在Eclipse中运行Jboss时出现java.lang.OutOfMemoryError:PermGen space及其解决方法 在Eclipse中运行Jboss时,时间太长可能有时候会出现java ...

随机推荐

  1. APP 自动化之手势操作appium提供API详解(四)

    一.手势操作1.上下左右滑屏 swipe---滑动 java-client 4.x 是有swipe方法的,可以通过传递坐标信息就可以完成滑动androidDriver.swipe(startx, st ...

  2. 攻防世界 WEB 高手进阶区 NSCTF web2 Writeup

    攻防世界 WEB 高手进阶区 NSCTF web2 Writeup 题目介绍 题目考点 php基本函数语法 加密解密函数 base64_decode().str_rot13() 字符串反转函数 str ...

  3. 带你理解MST性质

    写在前面 最小生成树的引出 假设要在n个城市之间建立通信联络网,则连通n个城市需要n-1条线路.在这种情况下,我们自然需要考虑一个问题,如何在最节省经费的条件下建立这个网络? 很自然地我们会想到,将各 ...

  4. Part 27 Remove # from URL AngularJS

    There are 4 simple steps to remove # from URLs in Angular. Step 1 : Enable html5mode routing. To do ...

  5. MySQL基础语句(修改)

    ①INSERT INSERT INTO students (class_id, name, gender, score) VALUES (2, '大牛', 'M', 80); 向students表插入 ...

  6. 【JAVA】笔记(8)--- java.lang.String 精讲

    String 特性: 1.String 表示字符串类型,属于引用数据类型,所以其储存的是地址: 2.java 中规定,双引号括起来的字符串是不可变的,也就说" name "永远也只 ...

  7. 『学了就忘』Linux软件包管理 — 48、给源码包打补丁

    目录 1.补丁的生成 2.补丁的打入 在以前的软件源码包,需要打补丁的时候比较多.现在的源码包很少进行打补丁了,因为根据需求安装不同的版本即可,比较商业化了.(也就是知道如何给源码包打补丁就可以了,了 ...

  8. 【JVM】JVM 概述、内存结构、溢出、调优(基础结构+StringTable+Unsafe+ByteBuffer)

    什么是 JVM ? 定义 Java Virtual Machine - java 程序的运行环境(java 二进制字节码的运行环境) 好处 一次编写,到处运行 自动内存管理,垃圾回收功能 数组下标越界 ...

  9. .net工程师学习vue的心路历程(二)

    本章主要搞懂在通过vue init webpack projectname 命令创建 vue 项目过程中有个选择.即关于如何选择:runtime+compiler和runtime+only. 现在我通 ...

  10. ErrorProvider与CheckedListBox

    http://www.cnblogs.com/myshell/archive/2010/09/24/1834184.html 最近因为做WinForm的项目,遇到这个问题,当时以为CheckedLis ...