启动 Equinox 时出现 The System Bundle's start level can not be modified. 错误

使用 Eclipse 的 OSGI 实现 Equinox,通过 config.ini 配置文件在命令行时启动 Equinox 时,可以进到 osgi> 是提示符,但是除 org.eclipse.osgi_3.5.2.R35x_v20100126 是 STARTING 外,其他的 Bundle 都是 RESOLVED 状态,没法进入到 ACTIVE 状态,osgi> start xxx 也不行。

然后看目录 configuration 目录中生成的日志文件,是如下错误:

!SESSION 2010-03-30 11:40:40.156 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_18
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=zh_CN
Command-line arguments:  -console

!ENTRY org.eclipse.osgi 4 0 2010-03-30 11:40:42.156
!MESSAGE Startup error
!STACK 1
java.lang.IllegalArgumentException: The System Bundle's start level can not be modified.
 at org.eclipse.osgi.framework.internal.core.StartLevelManager.setBundleStartLevel(StartLevelManager.java:371)
 at org.eclipse.core.runtime.adaptor.EclipseStarter.installBundles(EclipseStarter.java:1060)
 at org.eclipse.core.runtime.adaptor.EclipseStarter.loadBasicBundles(EclipseStarter.java:631)
 at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:301)
 at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:175)
 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:559)
 at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
 at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
 at org.eclipse.equinox.launcher.Main.main(Main.java:1287)

再看看 config.ini 文件中内容是

osgi.noShutdown=true

osgi.bundles=UserValidatorBundle_1.0.0.201003301134.jar@start,\
             LdapValidatorBundle_1.0.0.201003301134.jar@start,\
             DbValidatorBundle_1.0.0.201003301134.jar@start,\
             org.eclipse.osgi_3.5.2.R35x_v20100126.jar@start

osgi.bundles.defaultStartLevel=4

以为是不能设置 osgi.bundles.defaultStartLevel 属性,把该行去掉了,故障依旧;又以为框架包 org.eclipse.osgi_3.5.2.R35x_v20100126.jar 应该放在最前面,调了下个,一样的错误。

古鸽到了 Running Eclipse RCP applications in IntelliJ 9, 有人犯一样的错误,回复里面说啦:

Your start configuration contains the bundle org.eclipse.osgi, which is the system bundle for Equinox.

Please remove it from the list of bundles to be installed.

做法就是在 osgi.bundles 中不要写那个 Equinox 的框架包 org.eclipse.osgi_3.5.2.R35x_v20100126.jar,config.ini 写成:

osgi.bundles=UserValidatorBundle_1.0.0.201003301134.jar@start,\
             LdapValidatorBundle_1.0.0.201003301134.jar@start,\
             DbValidatorBundle_1.0.0.201003301134.jar@start

就 OK 啦,现在你的 Bundle 都可以激活了。

你的 org.eclipse.osgi_3.5.2.R35x_v20100126.jar 包仍然需要躺在目录 plugins 目录中,只是它是核心的包,不需要你手工来加载。如果 org.eclipse.osgi_3.5.2.R35x_v20100126.jar 文件也不存在,启动时日志里你将会看到这样的信息:

!SESSION Tue Mar 30 11:46:24 CST 2010 ------------------------------------------
!ENTRY org.eclipse.equinox.launcher 4 0 2010-03-30 11:46:24.484
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.lang.RuntimeException: Could not find framework
 at org.eclipse.equinox.launcher.Main.getBootPath(Main.java:880)
 at org.eclipse.equinox.launcher.Main.basicRun(Main.java:498)
 at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
 at org.eclipse.equinox.launcher.Main.main(Main.java:1287) 

 

 

参考: 1. Running Eclipse RCP applications in IntelliJ 9

类别: Java/JEE. 标签: , . 阅读(747). 订阅评论. TrackBack.

Leave a Reply

Be the First to Comment!

avatar