运行Equinox控制台报错Could not find bundle: org.eclipse.equinox.console

           我对Java的每一种技术都感兴趣,尤其是在了解到OSGi时,虽然这几年无人问津,但是我决定去学习一下,买了一本周志明编著的《深入理解OSGi---Equinox原理、应用于最佳实践》一书,在看到第三章时,书上说要运行本节的例子请先看第5章将Equinox的开发环境搭建好,书中例举了三种不同环境搭建方案;最简单的一种是安装好jdk和eclipse,然后在eclipse的安装目录下的plugins目录下进入命令提示符(cmd),输入

     

      >java  -jar  org.eclipse.osgi_3.10.2.v20150203-1939.jar  -console

     

      按理说,根据书中例子正常的话,屏幕会出现Equinox OSGi控制台的提示符“osgi>",但是我的屏幕没有反应,并且我注意到plugins目录下新生成一个configuration目录,目录里面有日志文件,打开日志提示报错信息如下:

!SESSION 2018-01-10 15:52:00.547-----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_151
java.vendor=Oracle Corporation
BootLoader constants:OS=win32,ARCH=x86_64,WS=win32,NL=zh_CN
Command-line arguments:-console

!ENTRY org.eclipse.osgi 4 0 2018-01-10 15:52:01.385
!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.core.runtime.internal.adaptor.ConsoleManager.checkForConsoleBundle(ConsoleManager.java:58)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:331)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:231)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.main(EclipseStarter.java:208)

!ENTRY org.eclipse.osgi 4 0 2018-01-10 15:52:01.397
!MESSAGE Application error
!STACK 1
java.lang.IllegalStateException:Unable to acquire application service.Ensure that the org.eclipse.core.runtime bundle is resolved and started(see config.ini).
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:78)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.main(EclipseStarter.java:208)

           

       我的eclipse版本为

       Version: Luna Service Release 2 (4.4.2)
       Build id: 20150219-0600

     

       在网上搜索一番得知新版本Equinox osgi shell已被felix gogo shell代替,如果要在新版本中使用控制台,那就要替换gogo 的jar包,并且要在配置文件中定义。书上的eclipse版本为3.x,所以没有这个问题,如果你出现和我一样的问题,一起按照如下步骤改一下吧:

    

       刚才不是在plugins目录下生成一个configuration目录嘛,紧接着在configuration目录下新建一个config.ini,或者将和plugins目录平级的configuration目录下的config.ini拷贝过来,将两个config.ini里面的osgi.bundles修改为如下,我贴一下整个config.ini整个内容:

#This configuration file was written by: org.eclipse.equinox.internal.frameworkadmin.equinox.EquinoxFwConfigFileParser
#Wed Jan 10 12:58:09 CST 2018
org.eclipse.update.reconcile=false
eclipse.p2.profile=epp.package.java
osgi.instance.area.default=@user.home/workspace
osgi.framework=file\:plugins/org.eclipse.osgi_3.10.2.v20150203-1939.jar
equinox.use.ds=true
eclipse.buildId=4.4.2.M20150204-1700
#将原来的注释掉,其他属性不要动
#osgi.bundles=reference\:file\:org.eclipse.equinox.simpleconfigurator_1.1.0.v20131217-1203.jar@1\:start
#这是最新的,注意jar包版本号要改成你自己的,这些jar可以在plugins目录下搜到
osgi.bundles=file\:org.eclipse.equinox.console_1.1.0.v20140131-1639.jar@start,file:\org.apache.felix.gogo.command_0.10.0.v201209301215.jar@start,file:\org.apache.felix.gogo.runtime_0.10.0.v201209301036.jar@start,file:\org.apache.felix.gogo.shell_0.10.0.v201212101605.jar@start

org.eclipse.equinox.simpleconfigurator.configUrl=file\:org.eclipse.equinox.simpleconfigurator/bundles.info

eclipse.product=org.eclipse.platform.ide

osgi.splashPath=platform\:/base/plugins/org.eclipse.platform

osgi.framework.extensions=reference\:file\:org.eclipse.osgi.compatibility.state_1.0.1.v20140709-1414.jar

osgi.bundles.defaultStartLevel=4

eclipse.p2.data.area=@config.dir/../p2/

eclipse.application=org.eclipse.ui.ide.workbench

    

    改完后,保存,重新打开cmd命令行,再输入就OK了

  参考地址:https://stackoverflow.com/questions/11161871/org-osgi-framework-bundleexception-could-not-find-bundle-org-eclipse-equinox-c

                       

!SESSION 2018-01-03 19:56:48.518 ----------------------------------------------- eclipse.buildId=M20130204-1200 java.version=9.0.1 java.vendor=Oracle Corporation BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=zh_CN Framework arguments: -product com.android.ide.eclipse.adt.package.adtproduct Command-line arguments: -os win32 -ws win32 -arch x86_64 -product com.android.ide.eclipse.adt.package.adtproduct !ENTRY org.eclipse.equinox.simpleconfigurator 4 0 2018-01-03 19:56:51.800 !MESSAGE FrameworkEvent ERROR !STACK 0 org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.simpleconfigurator_1.0.301.v20120914-163612 [5]" could not be resolved. Reason: Missing Constraint: Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,J2SE-1.4 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 2018-01-03 19:56:51.815 !MESSAGE Bundle initial@reference:file:plugins/org.eclipse.equinox.simpleconfigurator_1.0.301.v20120914-163612.jar was not resolved. !ENTRY org.eclipse.osgi 2 0 2018-01-03 19:56:51.847 !MESSAGE One or more bundles are not resolved because the following root constraints are not resolved: !SUBENTRY 1 org.eclipse.osgi 2 0 2018-01-03 19:56:51.847 !MESSAGE Bundle initial@reference:file:plugins/org.eclipse.equinox.simpleconfigurator_1.0.301.v20120914-163612.jar was not resolved. !SUBENTRY 2 org.eclipse.equinox.simpleconfigurator 2 0 2018-01-03 19:56:51.847 !MESSAGE Missing required capability Require-Capability: osgi.ee; filter="(|(&(osgi.ee=CDC/Foundation)(version=1.1))(&(osgi.ee=JavaSE)(version=1.4)))". !ENTRY org.eclipse.osgi 2 0 2018-01-03 19:56:51.862 !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 2018-01-03 19:56:51.862 !MESSAGE Bundle org.eclipse.equinox.simpleconfigurator_1.0.301.v20120914-163612 [5] was not resolved. !SUBENTRY 2 org.eclipse.equinox.simpleconfigurator 2 0 2018-01-03 19:56:51.862 !MESSAGE Missing required capability Require-Capability: osgi.ee; filter="(|(&(osgi.ee=CDC/Foundation)(version=1.1))(&(osgi.ee=JavaSE)(version=1.4)))". !ENTRY org.eclipse.osgi 4 0 2018-01-03 19:56:51.894 !MESSAGE Application error !STACK 1 java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini). at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:74) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) 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)
©️2020 CSDN 皮肤主题: 深蓝海洋 设计师:CSDN官方博客 返回首页