VMware {code} Community
virat1234
Enthusiast
Enthusiast

Using bundle-classpath while debugging in eclipse

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?

0 Kudos
7 Replies
laurentsd
VMware Employee
VMware Employee

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.

0 Kudos
virat1234
Enthusiast
Enthusiast

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.

0 Kudos
laurentsd
VMware Employee
VMware Employee

There is no reason to package your bundle differently between dev and production mode.  You're looking for trouble 🙂

0 Kudos
virat1234
Enthusiast
Enthusiast

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?

0 Kudos
virat1234
Enthusiast
Enthusiast

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

0 Kudos
virat1234
Enthusiast
Enthusiast

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.

0 Kudos
laurentsd
VMware Employee
VMware Employee

Still puzzled that you package jars differently between dev and production but I am glad you found the solution!

0 Kudos