hstaudacher / osgi-jax-rs-connector

An OSGi - JAX-RS 2.0 Connector, software repository available on the link below
http://hstaudacher.github.io/osgi-jax-rs-connector
Other
191 stars 98 forks source link

Setting the root to "/" #114

Closed retog closed 8 years ago

retog commented 8 years ago

I would like jax-rs to be enable at the root URI Path, i.e. a resource with @Path("") to be available at http://<myhost>/. However while setting the root property in the com.eclipsesource.jaxrs.connector to any other value woks as expected, setting it to / or to the empty string doesn't work as expected.

hstaudacher commented 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.

retog commented 8 years ago

I'm using Felix

hstaudacher commented 8 years ago

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 :)

retog commented 8 years ago

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.

hstaudacher commented 8 years ago

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.

retog commented 8 years ago

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.