Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find out dependencies for a any .jar bundle

Tags:

java

osgi

bundles

I am developing OSGi bundles using Eclipse. I test the code, using an Eclipse OSGi runtime configuration.

The code works fine there, but when I export the bundles as jars and try to use them in another environment (pax-runner, for instance) I get ClassNotFound exceptions at runtime. The bundles are installed fine, with no errors. I execute the command on equinox: "diag bundle-number" and it says: "No unresolved constraints" for every bundle.

I would like to know if there is a tool/method to know, for a given .jar bundle if it needs any external library, which is not described in the manifest.mf.

like image 896
Hectoret Avatar asked Dec 20 '25 14:12

Hectoret


2 Answers

Your bundle will resolve if all the packages listed in Import-Package (and the bundles listed in Require-Bundle) are found at runtime. If you get ClassNotFoundException or NoClassDefFoundError after resolving, it means that the content of Import-Package was wrong.

Take a look at the Bnd tool by Peter Kriens. This performs static inspection of the bytecode compiled from your classes to discover the exact dependencies, and it generates the Import-Package statement for you. In general if you use Bnd, you should never see ClassNotFound/NoClassDefFound unless dynamically load classes by name, e.g. with Class.forName().

like image 160
Neil Bartlett Avatar answered Dec 23 '25 04:12

Neil Bartlett


JBoss has just release a fantastic Open Source diagnostic tool about dependencies : http://jboss.org/tattletale

One of the features is to analyse the jar files by introspection, to find all lacking dependencies.

like image 43
Benoit Courtine Avatar answered Dec 23 '25 04:12

Benoit Courtine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!