I've been trying to make an OSGI REST bundle. I've baked it down to a contrived minimized example with a single bundle workspace with a single class that uses a few annotations. I get errors resolving the javax.ws.rs package when I run the bundle through Eclipse. I have added the javax.ws.rs-api 2.0.1 to the cnf project and added the javax.ws.rs-api-2.0.1.jar to the build path of my bundle.
When I run the bundle I get the following error:
! could not resolve the bundles: [myprovider-1.0.0.201704280130 org.osgi.framework.BundleException: Unable to resolve myprovider [1](R 1.0): missing requirement [myprovider [1](R 1.0)] osgi.wiring.package; (&(osgi.wiring.package=javax.ws.rs)(version>=2.0.0)(!(version>=3.0.0))) Unresolved requirements: [[myprovider [1](R 1.0)] osgi.wiring.package; (&(osgi.wiring.package=javax.ws.rs)(version>=2.0.0)(!(version>=3.0.0)))] ] ! Failed to start bundle myprovider-1.0.0.201704280130, exception Unable to resolve myprovider [1](R 1.0): missing requirement [myprovider [1](R 1.0)] osgi.wiring.package; (&(osgi.wiring.package=javax.ws.rs)(version>=2.0.0)(!(version>=3.0.0))) Unresolved requirements: [[myprovider [1](R 1.0)] osgi.wiring.package; (&(osgi.wiring.package=javax.ws.rs)(version>=2.0.0)(!(version>=3.0.0)))]
My bundle's bnd.bnd is:
-buildpath: \
javax.ws.rs-api;version=2.0,\
osgi.cmpn,\
osgi.core
-runrequires: \
osgi.identity; filter:='(osgi.identity=org.apache.felix.gogo.command)',\
osgi.identity; filter:='(osgi.identity=org.apache.felix.gogo.runtime)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)'
-runfw: org.apache.felix.framework;version='[5.4.0,5.4.0]'
-runee: JavaSE-1.8
Export-Package: myprovider
What I was originally trying to do is almost the same as in this question:
Error implementing a OSGI REST: `OSGi bundle not started : missing requirement`
However, the resolution to that issue is something I already have in my bnd file.
You should split your bnd.bnd file into two files.
bnd.bnd defines the rules to build the single bundle. So buildpath as well as tuned settings like Import-Packages belong there.
app.bndrun or similar. You need to at least define an index and runrequires there. The runrequires should include your user bundle.
To make your bundle at least resolve you also need to add a jaxrs api bundle to your index. This is not enough though. You will also need a jaxrs implementation and you will also need to publish your rest service. There are some ways to achive that. Once of them is CXF-DOSGi.
There is a REST example using bnd to build the bundle.
There is also an index and a bndrun file. The bndrun also includes the rest example even if it is in the soap example.