Java自学者论坛

 找回密码
 立即注册

手机号码,快捷登录

恭喜Java自学者论坛(https://www.javazxz.com)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,会员资料板块,购买链接:点击进入购买VIP会员

JAVA高级面试进阶训练营视频教程

Java架构师系统进阶VIP课程

分布式高可用全栈开发微服务教程Go语言视频零基础入门到精通Java架构师3期(课件+源码)
Java开发全终端实战租房项目视频教程SpringBoot2.X入门到高级使用教程大数据培训第六期全套视频教程深度学习(CNN RNN GAN)算法原理Java亿级流量电商系统视频教程
互联网架构师视频教程年薪50万Spark2.0从入门到精通年薪50万!人工智能学习路线教程年薪50万大数据入门到精通学习路线年薪50万机器学习入门到精通教程
仿小米商城类app和小程序视频教程深度学习数据分析基础到实战最新黑马javaEE2.1就业课程从 0到JVM实战高手教程MySQL入门到精通教程
查看: 387|回复: 0

在Eclipse中运行OSGI工程出错的解决方案

[复制链接]
  • TA的每日心情
    奋斗
    4 天前
  • 签到天数: 799 天

    [LV.10]以坛为家III

    2050

    主题

    2108

    帖子

    72万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    725076
    发表于 2021-6-9 16:40:51 | 显示全部楼层 |阅读模式

    今天学习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命令,可以看到如下的详情:

     
     
    另外 :需添加配置参数
     

     

    哎...今天够累的,签到来了1...
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|小黑屋|Java自学者论坛 ( 声明:本站文章及资料整理自互联网,用于Java自学者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

    GMT+8, 2024-11-1 08:21 , Processed in 0.060301 second(s), 29 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表