1
votes

I'm having the following situation:

I want to extend the functionality of a given plugin A (I have it's source code and start it by running the project as an Eclipse Application which opens a new Eclipse IDE which provides the plugins functionality) with an plugin B I am writing.

My plugin does run when I run it as a Java Application. Let's assume it just prints Hello World in the console. What I want is that I can call the function which does that from plugin A.

What I did:

  1. I added my plugin B to plugin As Required Plugin-Ins.
  2. I create an instance of the class which implements the Hello World-print and call the function inside a method of plugin A (I also tried to make the method static and call it without creating an instance which resulted in exactly the same errors).
  3. I created an Extension Point in plugin B and added it as an Extension in plugin A. I just set the ID and name in the Extension Point.

What happens:

When the instance of the class in plugin B should be created, the program crashes with this error:

java.lang.NoClassDefFoundError: de/name_of/plugin_b/package/ClassName
[...]
Caused by: java.lang.ClassNotFoundException: de.name_of.plugin_b.package.ClassName cannot be found by de.name_of.plugin_a.package_1.0.0.qualifier

I guess I'm missing something imporant - can someone help me out on what it is?

Edit 2:

I've just read that I have to add "." to the classpath. Seems like this solved the issue! Thanks for making me dig deeper into the manifest, greg!

I do get a different error now tho, which also seems to be connected to me making mistakes when creating the plugin as I do not get this error when I run plugin B as a Java Application.

java.lang.NoSuchMethodError: org.apache.lucene.store.FSDirectory.open(Ljava/nio/file/Path;)Lorg/apache/lucene/store/FSDirectory;

The problem is, tho, that this method does exists (see lucene API here).

As seen in the manifest, I added the lucene-jars to the dependencies of plugin B.

1
Show us the MANIFEST.MF for the two plugins.greg-449
I edited the two manifests into the OP.Jdv

1 Answers

2
votes

You need to include every package that other plugins use in the Export-Package section of your plugin. In the MANIFEST.MF editor this is on the 'Runtime' tab in the 'Exported Packages' section.

You don't need an extension point to make this work.