Hi there!
Currently I'm trying to execute some bundles using the capabilities of the EclipseStarter class. If I run my program directly from Eclipse the OSGi service bundle is loaded and I'm able to install and start other bundles.
But if I export my java program to a executable jar-file and run it from the command line the environment loads a bundle called "System Bundle [0]" instead of the OSGi service bundle. Every attempt to install a new bundle causes a Nullpointer-Exception.
Do I have to set some special configuration within the Framework properties to be able to use the OSGi environment from the jar file? Currently I'm only setting the following two values:
frameworkProperties.put("osgi.clean", "true");
frameworkProperties.put("osgi.console", "true");
Update:
I think my problem might have something to do with the used java classpath. If I add the Framework-Bundle to the classpath like this
java -classpath /home/markus/org.eclipse.osgi_3.4.3.R34x_v20081215-1030.jar:test.jar
Starter.Starter
everything is working well:
osgi> ss
Framework is launched.
id State Bundle
0 ACTIVE org.eclipse.osgi_3.4.3.R34x_v20081215-1030
But if I only run the jar file I'm getting the following error log:
markus@markus-laptop:~/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)
Currently I'm using the framework-jar-file as an external library within my Eclipse project. I think that somethings goes wrong when I export my project to an executable file ...
BR,
Markus