0

Currently I'm working with osgi and karaf.

My problem is the no "osgi ready" dependencies , which means a jar that is not ready to be deployed as a bundle into karaf for example.

I tried two solutions in order to deal with this kind of problems :

  • I tried to to use "Embed-Dependency" which will include the jar
    dependency with the project... I don't think this could be a solution because when I try to embed the jar , it will ask me to include other jars that the first jar depend on , and so on ..

  • I tried to convert the no "osgi ready" jars into bundles using bnd tool or from "Plug-in from Existing JAR Archive" from eclipse project. And this led to the same result , each jar will call another jar that it depend on it..

I am not sure if I'm doing it the wrong way or what is the problem exactly. Any tips how to deal with no osgi ready dependencies ?

larnouch
  • 189
  • 1
  • 15

1 Answers1

3

The simplest way to start is to use the wrap: protocol to auto create a jar. Behind the scenes it uses bnd to create a bundle on the fly. Simply prepend wrap: to the mvn url of the jar.

When you try to install the jar using bundle:install -s wrap:mvn:... karaf will tell you which imported packages are missing. Install jars that provide these packages in the same way. The pom of the jar can give you a hint what is missing.

This can mean to install lots of jars if your initial jars has lots of dependencies.

Once you have a list of jars that are installable together you can either create a feature using wrap protocol or you can make bundles from the individual at build time.

In any case you should take a look are the servicemix bundles. It provides OSGi ready bundles for many libraries.

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64
  • thanks for the answer , but after i did osgified the bundles , I always get a java.lang.NoClassDefFoundError. Before that I had many exceptions of class not found , and I fixed that with exporting the needed packages. – larnouch Apr 18 '17 at 13:11