I am new to OSGI and I am trying to figure out how I resolve errors such as the one below
org.osgi.framework.BundleException: Unresolved constraint in bundle org.foo.serviceBundle [253]: Unable to resolve 253.0: missing requirement [253.0] package; (&(package=org.slf4j)(version>=1.6.0)(!(version>=2.0.0)))
I used a maven archetype to generate a bundle and added some simple slf4j logging to my Activator class. I am also using the maven bundle plugin as follows:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.2.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Activator>org.shoppingsite.Activator</Bundle-Activator>
</instructions>
</configuration>
</plugin>
I have tried other combinations and I get one package or the other that is not resolvable. I am trying to deploy the bundle onto GlassFish appserver. Any help will be appreciated
Thank you
This usually means that you're missing a bundle that exports org.slf4j. Here's the whole workflow:
The maven-bundle-plugin will make sure that your own project's manifest imports org.slf4j (since you need it).
The maven dependencies in your project's POM will make sure that the slf4j artifact is downloaded
Then 2 things can go wrong:
either your compilation failed and the slf4j artifact wasn't found (but I suppose you'd have noticed that)
or the slf4 artifact you downloaded does not have a Manifest or is not exporting org.slf4j. To check it out, simply look into the manifest of the org.slf4j bundle. If you are running things directly in an IDE like eclipse, you might want to check in $HOME/.m2/ instead to find the artifact.
If your artifact doesn't have a proper manifest, you'll have to either find some other repo you can get a proper bundle from, or modify the one you're getting and installing it on your local repository (and deploying it on your local maven bundle repository (e.g. nexus) if you have one)
Last little thing: consider using the maven-scr plugin instead of directly defining activators and service discovery. I wish I had known that when I started with OSGi!