Skip to content
Advertisement

Simple OSGi application with dependencies inside bundle

Simple OSGi application with dependencies inside bundle.

I am playing with karaf. I started by writing a simple rest application. https://github.com/YaroslavTir/osgi-jersey-hibertate/tree/stackoverflow/examples/karaf-rest-core

I took karaf examples as backbond and it was quite simple to run my first bundle with rest endpoints, but then I faced an issue when I added maven dependency. I added guava as an example and got an exception when installing the bundle in karaf

JavaScript

Error executing command: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=karaf-rest-core-blueprint; type=karaf.feature; version=”[4.3.1.SNAPSHOT,4.3.1.SNAPSHOT]”; filter:=”(&(osgi.identity=karaf-rest-core-blueprint)(type=karaf.feature)(version>=4.3.1.SNAPSHOT)(version<=4.3.1.SNAPSHOT))” [caused by: Unable to resolve karaf-rest-core-blueprint/4.3.1.SNAPSHOT: missing requirement [karaf-rest-core-blueprint/4.3.1.SNAPSHOT] osgi.identity; osgi.identity=org.apache.karaf.examples.karaf-rest-core-blueprint; type=osgi.bundle; version=”[4.3.1.SNAPSHOT,4.3.1.SNAPSHOT]”; resolution:=mandatory [caused by: Unable to resolve org.apache.karaf.examples.karaf-rest-core-blueprint/4.3.1.SNAPSHOT: missing requirement [org.apache.karaf.examples.karaf-rest-core-blueprint/4.3.1.SNAPSHOT] osgi.wiring.package; filter:=”(&(osgi.wiring.package=com.google.common.collect)(version>=29.0.0)(!(version>=30.0.0)))”]]

I read somewhere that org.apache.felix.maven-bundle-plugin has a bug and add optional dependency to the bundle, and this looks like true, as I can see in MANIFEST.MF/Import-Package dependncy like com.google.appengine.api that should not be there. :

JavaScript

I know that should be super simple, and I just miss some small but important detail.

Advertisement

Answer

Your error means that your bundle karaf-rest-core-blueprint has a dependency on com.google.common.collect and this dependency can’t be resolved in the container.

In other words, you did’nt install guava into Karaf.

JavaScript

In a real app, you should create a feature which installs all your dependencies/bundles.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement