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.
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().
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With