Community
Participate
Working Groups
Build Identifier: M20080911-1700 and M20090917-0800 Linux 64 I need to load plugin when some condition is satisfied. I used BundleContext::install and Bundle::start and it always fails with exceptions org.osgi.framework.BundleException: The activator myplugin.Activator for bundle myplugin is invalid Caused by: java.lang.ClassNotFoundException: myplugin.Activator Reproducible: Always Steps to Reproduce: 1.Create "Hello Word" plugin development project 2.Export the plugin and close the project 3.Create RPC Main project for rpc development 4. Add the following code in Activator::start(BundleContext context) String location = "reference:file:<myplugin full path>"; Bundle b = context.installBundle(location); try { // start the plugin explicitly b.start(Bundle.START_TRANSIENT); System.out.println("-I- Started bundle myplugin"); } catch ( BundleException e ) { // Handle errors e.printStackTrace(); System.out.println("-E- Error load bundle myplugin"); } 5. Run rpc and get exception on startup.
What exception? PW
Does the bundle you install have the myplugin.Activator class included in it? Could you attach a testcase, I cannot reproduce with my own bundle.
Created attachment 175710 [details] myRcp and myplugin ecilpse project directories Hi, I created tar gzip for eclipse directories of myRpc and myplugin. You may see the exact contents of the classes. Do you try to reproduce on Linux 64? Regards, Stella
I was also able to get it working with the 2 plugin templates mentioned, and the code from below. The only change I had to make was to add extra plugins to the launch config (org.eclipse.jface.text in my case) so that the bundle could load. PW
(In reply to comment #3) > Created an attachment (id=175710) [details] > myRcp and myplugin ecilpse project directories > You use this path: /home/slevin/kfir/pw/myplugin Is this the location of your plugin in your workspace? if that's the case, this will not work. Please attach a version of the plugins that would work when your product is exported (hint, you should see myplugin_1.0.0.jar) and then re-open. PW
.
Hi, The directory in context.installBundle(location) is a directory where the plugin was exported. Attached files: pw.tgz - workspace, pw_2.tgz - export directory. Thanks, Stella
>The only change I had to make was to add extra plugins to the launch config >(org.eclipse.jface.text in my case) so that the bundle could load. I added org.eclipse.jface.text to run configuration of the myRpc. It was not helpful. Did you mean this? Thanks, Stella
(In reply to comment #7) > Attached files: pw.tgz - workspace, pw_2.tgz - export directory. > Thanks, Stella It looks like you forgot to attach these files. PW
Created attachment 176773 [details] workspace directory
Created attachment 176774 [details] export plugin directory
pw_2 is not a valid plugin, you cannot load it. You need to take your myplugin from your original attachment and use File>Export...>Deployable plugins and fragments. The myplugin_1.0.0.jar that creates should be loadable by your activator. PW
(In reply to comment #12) > pw_2 is not a valid plugin, you cannot load it. > That should be pw_2/myplugin is not a valid plugin. PW
Please try with a deployed plugin. PW
Hi Paul, I get it working when use fullpath including jar: String location = "reference:file:<full path>/myplugin/plugins/myplugin_1.0.0.jar"; Bundle b = context.installBundle(location); Error was in writing location as a directory of exported plugin : String location = "reference:file:/home/slevin/kfir/pw_3/myplugin"; Thanks a lot. Stella
(In reply to comment #15) > Hi Paul, I get it working when use fullpath including jar: > String location = > "reference:file:<full path>/myplugin/plugins/myplugin_1.0.0.jar"; > Bundle b = context.installBundle(location); That means it's working when you export your plugin correctly (which is the only way it's supposed to work). closed. PW