OSGi JAX-RS Connector 2.0 released

OSGi JAX-RS Connector 2.0 released

Back in January 2012, I wrote about the release of the OSGi JAX-RS connector in version 1.0. The connector gives you the opportunity to publish resources by registering @Path annotated types as OSGi services. I’m glad to say that the connector is in production use in many projects. It is pretty stable and as a result there was not much need for maintenance. So, why release a version 2.0? A few weeks ago I wanted to provide a small REST API using Apache Karaf as runtime. For this I also wanted to use the JAX-RS connector. Unfortunately, I had to accept that the connector was not able to run on Karaf and Felix because of certain issues.

I had to rework some of the connector internals and update the Jersey bundles to 1.13.0ย to make it work. But, internal rework is no reason for a 2.0, right? Unless, during the rework something results in a breaking change. In version 1.0 of the connector all resources were registered on /. Sadly, this is not possible using Karaf and it’s HTTPService implementation. Therefore, the new root path of the registered resources is /services. The good news is that it’s configurable ;). You can use the config admin to change the root path. For this the service.pid isย com.eclipsesource.jaxrs.connector. The only property supported is root which needs to be a valid path (like with servlets, it has to begin with /).

To put it all together, the internal rework, the Jersey update and the new path gave me reason to bump it to 2.0 to make the breaking change visible. I hope you like the new version. As a reminder here are the most important resources:

GitHub repository:ย https://github.com/hstaudacher/osgi-jax-rs-connector

p2 repository:ย http://hstaudacher.github.com/osgi-jax-rs-connector

As always, feel free to comment ;).

<a href="http://twitter.com/hstaudacher"><img title="Follow @hstaudacher" src="http://download.eclipsesource.com/~hstaudacher/followme.png" alt="" width="191" height="58" border="0" /></a>

8 Comments
  • Lars Vogel
    Posted at 1:16 pm, August 28, 2012

    I’m not sure if see how to use this. Lets say I have a server which offers RESTful API, my assumption is what I could use your connector to publish these resources as OSGi services. And afterwards I could for example use OSGi remote services in an RCP application to connect to the server.

    Is that the right use case?

  • Hendy Irawan
    Posted at 3:11 pm, August 29, 2012

    Hi,

    For those interested, it’s also nice to use CXF in Karaf with JAX-RS support built-in. To register REST resources you use Blueprint.

    An example Blueprint XML for CXF & JAX-RS from our project : http://pastebin.com/CUjQmWrx

  • Hugo
    Posted at 10:38 pm, September 8, 2012

    Hi,
    I’m having a problem installing your connector to my OSGi instance, it gives the following error:

    The bundle “com.eclipsesource.jaxrs.connector_2.0.0.201208151950 [125]” could not be resolved. Reason: Missing Constraint: Import-Package: org.osgi.service.cm; version=”[1.4.0,2.0.0)”

    Do you know by any chance what’s the problem? Do you think your version 1.0 of the connector might solve the problem? Do you still have the link to version 1.0.0?

    Thank you

  • Chris Brind
    Posted at 12:45 am, October 24, 2012

    Hi Holger,

    Quick question, hopefully… I’m trying to get this running but the bundle seems to get stuck in the “starting” state. I wonder if I’m missing any dependencies or something? You can see my configuration here:

    https://dl.dropbox.com/u/2451973/Screen%20Shot%202012-10-23%20at%2023.48.53.png

    Thanks in advance.

    Cheers,
    Chris

  • Chris Brind
    Posted at 6:54 pm, October 24, 2012

    Nothing in the logs, thought manually stopping and starting it seems to get it in to the Active state. Haven’t had chance to test my resource yet though. ๐Ÿ™‚