I have made a small API Bundle and a service bundle that should use the API.
In my maven pom.xml file, i added a dependecy for my api bundle in the correct version like this:
<dependency>
<groupId>at.foobar.osgi.api</groupId>
<artifactId>foobarapi</artifactId>
<version>1.0</version>
</dependency>
i'm using the maven-bundle plugin to create the bundles, and because of that i used mvn clean install
to create by jar file.
The Manifest looks like this (the 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 OK for me. The import is in there, so everything should be fine.
now i started up equinox and installed the API and the producer bundle. Then i startet the API, which worked out 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 framework cannot find the api, but its installed and started?
Make sure that you are exporting the API packages, so that your service bundle can bind to them.
In your maven-bundle-plugin for the API bundle you should have something like:
<configuration>
<instructions>
<Import-Package>
*
</Import-Package>
<Export-Package>
at.foobar.osgi.api.*
</Export-Package>
</instructions>
</configuration>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With