Closed retog closed 8 years ago
Which OSGi implementation are you using? I made the experience that setting it to /
works in Equinox but not in Felix/Karaf.
I'm using Felix
Ok, so it's up to felix HttpService to allow registering servlets on /
. We can't do nothing here. I you have figured out a way to do this with Felix I would really appreciate a FAQ Entry, https://github.com/hstaudacher/osgi-jax-rs-connector/wiki/FAQ :)
It is absolutely possible to register servlets (and filters) at /
with felix. For a minimalistic HTTP-Whiteboard example just checkout out https://github.com/retog/simple-osgi-launcher/tree/master/examples/servlet-example and adapt the path in src/main/java/org/wymiwyg/simpleosgilauncher/example/servlet/HelloServlet.java
.
For an example using HttpService directly see https://github.com/apache/clerezza/blob/master/jaxrs.whiteboard.jersey/src/main/java/org/apache/clerezza/jaxrs/whiteboard/jersey/JerseyEndpoint.java, this is the module I was considering to replace with your project.
Btw, you might be interested in https://github.com/retog/simple-osgi-launcher/tree/master/examples/jaxrs-example for an example on how to create an executable jar launcher running the jaxrs-osgi application directly from the bundle project.
Hmm, we are using the old http service and this is where the servlet is registered: https://github.com/hstaudacher/osgi-jax-rs-connector/blob/master/bundles/com.eclipsesource.jaxrs.publisher/src/com/eclipsesource/jaxrs/publisher/internal/JerseyContext.java#L159
As you can see we don't do any magic here. Just taking the rootPath and call registerServlet.
So, I have no idea why this doe snot work with felix.
I tried debugging it, just to find out that somehow it started to work with /
. So https://github.com/retog/simple-osgi-launcher/tree/master/examples/jaxrs-example provides a minimalist example for osgi-jax-rs-connector
as an executable jar.
I would like jax-rs to be enable at the root URI Path, i.e. a resource with
@Path("")
to be available athttp://<myhost>/
. However while setting theroot
property in thecom.eclipsesource.jaxrs.connector
to any other value woks as expected, setting it to/
or to the empty string doesn't work as expected.