Search code examples
osgiosgi-bundlebndbndtools

OSGi companion bundle needed?


I have two different projects in Eclipse based on Bndtools. The first produces a JAR with following manifest :

Manifest-Version: 1.0
Bnd-LastModified: 1450251340248
Bundle-Activator: org.osgi.tutorial.MessageCounterActivator3
Bundle-ManifestVersion: 2
Bundle-Name: org.osgi.tutorial
Bundle-SymbolicName: org.osgi.tutorial
Bundle-Version: 0.0.0.201512160735
Created-By: 1.8.0_66 (Oracle Corporation)
Import-Package: org.osgi.book.reader.api,org.osgi.framework;version="[1.3,2)",org.osgi.util.tracker;version="[1.4,2)"
Private-Package: org.osgi.tutorial
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-3.0.0.201509101326

the second has the following manifest :

Manifest-Version: 1.0
Bnd-LastModified: 1450536025075
Bundle-Activator: org.osgi.book.configadmin.ServerConnectionActivator
Bundle-ManifestVersion: 2
Bundle-Name: org.osgi.book.configadmin
Bundle-SymbolicName: org.osgi.book.configadmin
Bundle-Version: 0.0.0.201512191440
Created-By: 1.8.0_66 (Oracle Corporation)
Import-Package: org.osgi.framework;version="[1.3,2)",org.osgi.service.cm;version="[1.3,2)"
Private-Package: org.osgi.book.configadmin;version="1.0.0"
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-3.0.0.201509101326

The two projects need the osgi.cmpn : the first for ServiceTracker (package org.osgi.util.tracker) and the second for ManagedService (package org.osgi.service.cm).

The first project works great : I install and start the bundle without problems. I can install the bundle from the second project but when I start it I receive the following error :

org.osgi.framework.BundleException: Unresolved constraint in bundle org.osgi.book.configadmin [6]: Unable to resolve 6.0: missing requirement [6.0] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.service.cm)(version>=1.3.0)(!(version>=2.0.0)))

What's the problem ? If both the project need osgi.cmpn JAR ... why the first doesn't throw this error on starting ?

Thanks, Paolo.


Solution

  • See this question. Never deploy the compendium jar in OSGi. Instead you need a bundle that implements the spec you depend on.

    In your case you need a config admin service impl. There are implementations from felix and from eclipse. Both contain the api.