Cant start osgi bundle because import cannot be allowed

I made a small set of APIs and a set of services that the API should use.

In my maven pom.xml file, I added the dependecy function for my api package in the correct version as follows:

<dependency> <groupId>at.foobar.osgi.api</groupId> <artifactId>foobarapi</artifactId> <version>1.0</version> </dependency> 

I use the maven-bundle plugin to create packages, and because of this, I used mvn clean install to create the jar file. The manifesto looks like this (service):

 Manifest-Version: 1.0 Private-Package: at.foobar.osgi.producer Built-By: foobar Tool: Bnd-0.0.238 Bundle-Name: foobarproducer Created-By: Apache Maven Bundle Plugin Bundle-Version: 1.0 Build-Jdk: 1.6.0_26 Bnd-LastModified: 1332185439257 Bundle-ManifestVersion: 2 Bundle-Activator: at.foobar.osgi.producer.Activator Import-Package: at.foobar.osgi.api,org.osgi.framework;version="1.4" Bundle-SymbolicName: at.foobar.osgi.producer.foobarproducer 

which seems to be suitable for me. Import there, so everything should be fine.

Now I started the equinox and installed the API and distribution. Then I launch the API, which works fine. But when I want to start the producer service, I get this error:

 org.osgi.framework.BundleException: The bundle "at.foobar.osgi.producer.foobarproducer_1.0.0 [4]" could not be resolved. Reason: Missing Constraint: Import-Package: at.foobar.osgi.api; version="0.0.0" 

It seems that the structure cannot find api, but is it installed and running?

+8
java maven bundle osgi
source share
1 answer

Make sure you export the API packages so that your service package can communicate with them.

In your maven-bundle plugin for the API package, you should have something like:

  <configuration> <instructions> <Import-Package> * </Import-Package> <Export-Package> at.foobar.osgi.api.* </Export-Package> </instructions> </configuration> 
+6
source share

All Articles