OSGi bundle imports packages from non-bundle jars: create bundles for them?

Posted by John Simmons on Stack Overflow See other posts from Stack Overflow or by John Simmons
Published on 2012-06-27T21:13:15Z Indexed on 2012/06/27 21:15 UTC
Read the original article Hit count: 195

Filed under:
|

I am new to OSGi, and am using Equinox. I have done several searches and can find no answer to this. The discussion at OSGI - handling 3rd party JARs required by a bundle helps somewhat, but does not fully answer my question.

I have obtained a jar file, rabbitmq-client.jar, that is already packaged as an OSGi bundle (with Bundle-Name and other such properties in its MANIFEST.MF), that I would like to install as a bundle. This jar imports packages org.apache.commons.io and org.apache.commons.io.input from commons-io-1.2.jar. The RabbitMQ client 2.7.1 distribution also includes commons-cli-1.1.jar, so I presume that it is required as well.

I examined the manifests of these commons jars and found that they do not appear to be packaged as bundles. That is, their manifests have none of the standard bundle properties.

My specific question is: if I install rabbitmq-client.jar as a bundle, what is the proper way to get access to the packages that it needs to import from the commons jars? There are only three alternatives that I can think of, without rebuilding rabbitmq-client.jar.

  1. The packages from the commons jars are already included in the Equinox global classpath, and rabbitmq-client.jar will get them automatically from there.
  2. I must make another bundle with the two commons jars, export the needed packages, and install that bundle in Equinox.
  3. I must put these two commons jars in the global classpath when I start Equinox, and they will be available to rabbitmq-client.jar from there.

I have read that one normally does not use the global classpath in an OSGi container. I am not clear on whether items from the global classpath are even available when building individual bundle classpaths. However, I note that rabbitmq-client.jar also imports other packages such as javax.net, which I presume come from the global classpath. Or is there some other bundle that exports them?

Thanks for any assistance!

© Stack Overflow or respective owner

Related posts about java

Related posts about jar