Question

I am trying to use Jersey through OSGi (Karaf, specifically). To do this, I downloaded this bundle jar from Maven and put it into my Karaf deploy directory. However, when I tried to start the bundle, it was unable to resolve any of it's dependancies. It also seemed to be looking for version 0.0.0 of each dependancy, which seems wrong.

What's the best way to get this bundle into my project? Do you I have to manually download all the dependancies, or can I use some existing OBR that has this bundle? Where would I find this?

Was it helpful?

Solution

I used Jersey with Karaf without problem using this dependencies instead of jersey-bundle:

<!-- Jersey -->
<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-core</artifactId>
    <version>1.12</version>
</dependency>

<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-server</artifactId>
    <version>1.12</version>
</dependency>

<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-json</artifactId>
    <version>1.12</version>
</dependency>   

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>jsr311-api</artifactId>
    <version>1.1.1</version>
</dependency> 

I've tested now on the last Karaf Apache console and this worked for me:

$ bin/karaf
  Apache Karaf (2.2.5)

karaf@root> install mvn:com.sun.jersey/jersey-core/1.12
Bundle ID: 49
karaf@root> install mvn:com.sun.jersey/jersey-server/1.12
Bundle ID: 50
karaf@root> install mvn:javax.ws.rs/jsr311-api/1.1.1
Bundle ID: 51
karaf@root> install mvn:com.sun.jersey/jersey-json/1.12
Bundle ID: 52
karaf@root> install mvn:org.codehaus.jackson/jackson-core-asl/1.9.5
Bundle ID: 53
karaf@root> install mvn:org.codehaus.jackson/jackson-jaxrs/1.9.5
Bundle ID: 54
karaf@root> install mvn:org.codehaus.jackson/jackson-mapper-asl/1.9.5
Bundle ID: 55
karaf@root> install mvn:org.codehaus.jettison/jettison/1.1
Bundle ID: 56
karaf@root> start 49 50 51 52 53 54 55 56
karaf@root> list 
   ID   State         Blueprint      Level  Name
[  49] [Active     ] [            ] [   60] jersey-core (1.12)
[  50] [Active     ] [            ] [   60] jersey-server (1.12)
[  51] [Active     ] [            ] [   60] jsr311-api (1.1.1)
[  52] [Active     ] [            ] [   60] jersey-json (1.12)
[  53] [Active     ] [            ] [   60] Jackson JSON processor (1.9.5)
[  54] [Active     ] [            ] [   60] JAX-RS provider for JSON content type, using Jackson data binding (1.9.5)
[  55] [Active     ] [            ] [   60] Data mapper for Jackson JSON processor (1.9.5)
[  56] [Active     ] [            ] [   60] jettison (1.1)

OTHER TIPS

I tried as well in Karaf (3.0.1) and it worked fined. I used Blueprint (in features.xml) and I added the following 3 JARs as bundles into my feature. I needed only for JSON conversion in a REST service.

<feature name="feature-name-test" version="${pom.version}">
  ....
  <bundle>mvn:org.codehaus.jackson/jackson-core-asl/${jackson.version}</bundle
  <bundle>mvn:org.codehaus.jackson/jackson-mapper-asl/${jackson.version}</bundle>
  <bundle>mvn:org.codehaus.jackson/jackson-jaxrs/${jackson.version}</bundle>
  ....
</feature>

where ${jackson.version} is a property which was defined in pom.xml (in my case 1.9.0). The same way works if you just install them from Karaf console.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top