I have added some 3rd party jars to my project using the bundle-classpath method and it works great. My question is how do I get these jars to load while debugging in eclipse? If I open my manifest.mf file in eclipse and navigate to the runtime tab, I do see the jars added under classpath. But when I launch virgo server and add my project, it says it cannot find classes within my dependencies.
How do I get around this?
If I understand your question:
- your bundle's MANIFEST.MF contains Bundle-ClassPath: .,myOtherLib.jar as described in the FAQ
- your bundle does include myOtherLib.jar at the root
- your plugin works fine when you start the Virgo server on the command line
- but when you start Virgo from Eclipse you get a dependency error because it cannot find classes from myOtherLib.jar
This is very strange, it shouldn't matter where the server was started from since it is the same plugin bundle, so I want to make sure this is your exact use case.
Sorry about the confusion, more information below
- your bundle's MANIFEST.MF contains Bundle-ClassPath: .,myOtherLib.jar as described in the FAQ
Yes
- your bundle does include myOtherLib.jar at the root
It does, but not in dev mode when I my plugin is in eclipse and I am running virgo from within eclipse (there is no mypluginservice.jar yet which contains all other jars at the root level). This jar is only built when packaging for production.
There is no reason to package your bundle differently between dev and production mode. You're looking for trouble 🙂
Well. We actually just import the project into eclipse like any other project. Do I need to copy my dependencies into the repository/usr folder like before?
Hi Laurent,
Any updates on this? As I have indicated above, when I am debugging my project in eclipse, eclipse does not generate a mypluginservice.jar which contains all other jars (this is usually done by our build script when packaging for production). If I launch Virgo in eclipse and add my plugin service project, it throws ClassNotFoundException, which indicates that my dependencies have not been loaded. I have placed all my dependency jars in the repository/usr folder. But it looks like Bundle-classpath: ., mylib1.jar, mylib2.jar does not actually pick up these. It did work before when I was using import-packages thought. So is there a workaround? Or do I have to maintain 2 manifest files, one that uses the import-package method and the other that uses the bundle-classpath method?
Virat
Never mind, I figured out that all I had to do was place all the dependency jars in the root of my source or resource folder and eclipse would include them. It will not include when if they are in its classpath alone.
Still puzzled that you package jars differently between dev and production but I am glad you found the solution!