Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Example using Jersey (REST resource), OSGi (Apache Felix), and Maven (build and deploy)?

Tags:

maven

jersey

osgi

I seem to be really struggling here. What I want to do (in this order) is:

1) Build a RESTful resource using a Jersey application and resource w/annotations (this is not the issue).

2) Package, install, and start that bundle into the Felix OSGi container, as an HTTP service, including dependencies.

3) Package, install, and start a WAR in the OSGi container that may incorporate #2 as a dependency.

And I would like to be able to do all of this using Maven.

I cannot seem to find a working example of even the individual steps, especially involving Maven, that work let alone the combination of those steps. I have tried cobbling together various q&a from across the web with varying levels of success but not an end-to-end working example yet.

Any pointers would be appreciated...

like image 922
KJQ Avatar asked Dec 06 '25 19:12

KJQ


2 Answers

I do not have an example for Jersey but I have a tutorial for CXF with Apache Karaf (which uses Felix). It shows how to create a Rest service and build it with maven. Using Apache Karaf you can then deploy the bundle directly from the maven repo. Moving this to Jersey probably just means to exchange the lib and use another blueprint config to initialize the rest service.

Apache Karaf also allows to deploy wars and wabs but I have not yet tested them.

like image 163
Christian Schneider Avatar answered Dec 08 '25 15:12

Christian Schneider


Apache Stanbol does most or all of this (not sure if the war packaging is included out of the box) to implement its RESTful services.

You'll have to dig through its codebase but searching for Jax-RS annotations in there should point you to the right places.

like image 36
Bertrand Delacretaz Avatar answered Dec 08 '25 17:12

Bertrand Delacretaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!