views:

493

answers:

2

Hi,

I have a serious probleam with my Eclipse Plugin..

My plugin depends on another two plugins. All of theese plugins (including my plugin) use Mozilla Rhino engine - two of them use js.jar (version 1.4). But my plugin uses new version, which is not released yet and is packed in MyRhino.jar.

While developing, everything goes fine - code completion offers me classes and methods from my special version of rhino, no errors etc.

But when I run my plugin, a different version of Rhino is used and I get runtime exceptions like ClassNotFoundException and so on.

How am I supposed to tell eclipse to use the same jar in runtime as in development time?

When I was developing plugins on NetBeans, the solution was simple - wrapping the jar in a separate module, set which packages to export and declare dependency on this new module.. I found simmilar solution in Eclipse, however it did not work for me - although I declared a dependency on the wrapper plugin, the packages and classes were not available even in development time.

I've spent hours with this probleam and not solved it, so and help is appreciated. Thanks everyone.

+3  A: 

Make sure your dependencies are correct. If your code depends on new version of library, then you need to indicate that in your MANIFEST.MF. E.g. if you require bundle org.mozilla.rhino, specify minimum version you need:

Require-Bundle: org.mozilla.rhino;bundle-version="1.5.0"

Your MyRhino.jar will need to specify correct version (e.g. 1.5.0), even though it is not released yet:

Bundle-Version: 1.5.0.qualifier

(If MyRhino.jar isn't converted to plugin yet, you need to do that manually: you can simply craete new plugin project using existing JAR in Eclipse)

Alternativaly, you can wrap MyRhino.jar into your plugin, and remove dependencies on other plugins. To do this, use Bundle-ClassPath (see http://www.aqute.biz/Blog/2007-02-19 for details). If you put your MyRhino.jar directly into your plugin, then Bundle-ClassPath should be:

Bundle-ClassPath: .,MyRhino.jar
Peter Štibraný
It looks like I'm missing something.. First of all I used the alternative way you describe. It did not work for me (as I wrote upwards). So now I've created a plugin from my existing jar and declared a dependency on this plugin. I have also removed the entry from Bundle-ClassPath. Then I refreshed the project and updated classpath.. Now I can see many errors in imports in my classes - classes from the jar-wrapped plugin are not seen in my plugin project. What am I doing worng?
Martin Lazar
+1  A: 

Finally I've solved it..

It's simple to create the wrapper plugin form existing jar by the new project wizard in eclipse.. But the catch is that the wizard does not include the jar in bundle classpath (as I expected). Prety confusing (at least for me) that the wizard does only half of the job for you :/

After inserting the jar in the wrapper plugin bundle classpath, everytning works.

Thanks Peter for your answear anyway :)

Martin Lazar
Good to hear that you solved it.
Peter Štibraný