How to Start a bundle programatically [message #509026] |
Thu, 21 January 2010 08:39 |
Cristina Messages: 8 Registered: January 2010 |
Junior Member |
|
|
Hello,
I have a plug-in implementing an osgi "server" and another one implementing a view of eclipse. Using the view, I want to control went to start and stop the server.
To do this, I need to be able to start and stop the bundle programatically whenever I need. What is the best way to do so? Or more important... is that possible?
I've try it by implementing the following code in the main method of a Java class.
<code>
String[] equinoxArgs = {"-console","1235","-noExit"};
BundleContext context = EclipseStarter.startup(equinoxArgs, null);
Bundle bundle= context.installBundle(
"E:/server.jar");
bundleServer.start();
</code>
If I run the Java class as an Eclipse Application it seems to work fine. The problem is when I try to run the plugin which is calling the class...
I run the plugin as an Eclipse Application to see how it works, and everything seems to be fine until I press the Start buttom, when I get the following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/adaptor/EclipseStarter
at eu.sofia.m3.osgi.sib.deploy.Start.main(Start.java:22)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.adaptor.EclipseStarter
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 1 more
Any clue about how to solve this problem? Or any alternative to start the bundle programatically?
Any help will be really appreciated.
Thanks in advance.
[Updated on: Thu, 21 January 2010 08:42] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.02993 seconds