目前我正在試圖執行使用EclipseStarter類的功能,一些包。如果我直接從Eclipse運行我的程序,OSGi服務包將被加載,我可以安裝並啓動其他包。如何配置OSGi環境,以便可以從EclipseStarter類使用它?
但是,如果我在我的java程序導出到一個可執行的JAR文件和命令行運行環境加載一個名爲捆綁「系統插件[0]」,而不是OSGi服務捆綁。每次嘗試安裝新的捆綁包都會導致Nullpointer-Exception。
我必須設置框架屬性中一些特殊的配置能夠從jar文件使用OSGi環境?目前,我只設置以下兩個值:
frameworkProperties.put("osgi.clean", "true");
frameworkProperties.put("osgi.console", "true");
更新:
我想我的問題可能有些事情要與所使用的Java類路徑。如果我的框架,包到classpath中這樣
java -classpath /home/markus/org.eclipse.osgi_3.4.3.R34x_v20081215-1030.jar:test.jar
Starter.Starter
一切運作良好:
osgi> ss
Framework is launched.
id State Bundle
0 ACTIVE org.eclipse.osgi_3.4.3.R34x_v20081215-1030
但如果我只運行jar文件,我發現了以下錯誤日誌:
[email protected]:~/configuration$ cat 1244201504478.log
!SESSION 2009-06-05 13:31:44.895 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_13
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=de_DE
Command-line arguments: -clean -console
!ENTRY org.eclipse.osgi 4 0 2009-06-05 13:31:44.897
!MESSAGE An unexpected runtime error has occurred.
!STACK 0
java.lang.NullPointerException
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.readStateData(BaseStorage.java:743)
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.getStateManager(BaseStorage.java:698)
at org.eclipse.osgi.baseadaptor.BaseAdaptor.getState(BaseAdaptor.java:390)
at org.eclipse.core.runtime.adaptor.EclipseStarter$1.bundleChanged(EclipseStarter.java:307)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:1234)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:211)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:141)
at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEventPrivileged(Framework.java:1518)
at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1469)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:281)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.launch(StartLevelManager.java:247)
at org.eclipse.osgi.framework.internal.core.SystemBundle.resume(SystemBundle.java:201)
at org.eclipse.osgi.framework.internal.core.Framework.launch(Framework.java:644)
at org.eclipse.osgi.framework.internal.core.OSGi.launch(OSGi.java:51)
at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:313)
at CanEmulator.OSGiFramework.run(OSGiFramework.java:119)
at java.lang.Thread.run(Thread.java:619)
!ENTRY System Bundle 4 0 2009-06-05 13:31:44.898
!MESSAGE
!STACK 0
java.lang.NullPointerException
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.readStateData(BaseStorage.java:743)
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.getStateManager(BaseStorage.java:698)
at org.eclipse.osgi.baseadaptor.BaseAdaptor.getState(BaseAdaptor.java:390)
at org.eclipse.core.runtime.adaptor.EclipseStarter$1.bundleChanged(EclipseStarter.java:307)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:1234)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:211)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:141)
at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEventPrivileged(Framework.java:1518)
at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1469)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:281)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.launch(StartLevelManager.java:247)
at org.eclipse.osgi.framework.internal.core.SystemBundle.resume(SystemBundle.java:201)
at org.eclipse.osgi.framework.internal.core.Framework.launch(Framework.java:644)
at org.eclipse.osgi.framework.internal.core.OSGi.launch(OSGi.java:51)
at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:313)
at CanEmulator.OSGiFramework.run(OSGiFramework.java:119)
at java.lang.Thread.run(Thread.java:619)
目前我使用的框架-JAR文件作爲我的Eclipse項目內外部庫。我想,當我在我的項目導出到一個可執行文件出頭順心......
BR,
馬庫斯
你是嵌入在應用程序的OSGi框架?或者它只是一個打算在另一個框架實例中運行的包?你使用的是哪種OSGi框架? – Cogsy 2009-06-03 08:37:31
我使用的是最新的Equinox OSGi框架:org.eclipse.osgi_3.4。3.R34x_v20081215-1030.jar – Markus 2009-06-04 11:32:41