There's a line in RadioHead song "Phew, for a minute there, I lost myself..." I nearly did loose myself yesterday as I tried to reproduce some of Roberto Rojas's work on deploying a JAX-RS service in FUSE ESB 4.0.0.3 (based on Apache Servicemix 4). Roberto's blog entry refers to a preview edition of FUSE ESB 4, and things have moved on since then.
Luckily, I was able to ping off some of the good folk on the CXF project - Dan Kulp, Sergey Beryozkin, and David Bosschaert, and they got me going again. There's been some reworking of the JAX-RS support in SMX4, and this you need to update the cxf-bundle in FUSE 4.0.0.3, as per below:
servicemix> osgi list | utils grep CXF
[ 89] [Active ] [ 50] ServiceMix :: CXF Binding Component (2008.01.0.fuse)
[ 105] [Active ] [ 50] Apache CXF Runtime JBI Binding (2.1.3.fuse)
[ 106] [Active ] [ 50] Apache CXF Runtime JBI Transport (2.1.3.fuse)
[ 107] [Active ] [ 50] ServiceMix :: CXF Service Engine (2008.01.0.fuse)
[ 142] [Active ] [ 50] Apache CXF Bundle Jar (2.1.3.fuse)
servicemix> osgi uninstall 142
servicemix> osgi install -s mvn:org.apache.cxf/cxf-bundle/2.1.3.3-fuse
FUSE ESB 4.0.0.4, released just last night (Feb 9th 2009), already uses version 2.1.3.3-fuse of cxf-bundle, so if you're using 4.0.0.4 then you shouldn't need this step.
With this in place, you can now go and deploy your restful service. For example, I threw together a bundle with a JAX-RS 0.8 service: to install it, I need to install a few dependencies into FUSE ESB 4:
First, we need the JAX-RS (JSR 311) api. I'm using version 0.8:
servicemix> osgi install -s wrap:mvn:javax.ws.rs/jsr311-api/0.8
Next, you need to install the specs locator and the servicemix jsr311-api bundle so that FUSE can locate and load up the spec and implementation correctly.
servicemix> osgi install -s mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.locator
servicemix> osgi install -s mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jsr311-api-0.8
While my example isn't using JSON, there is currently a runtime dependency on Jettison, so you need to install that too. You can use the bundle from SpringSource like this:
servicemix> osgi install -s mvn:org.codehaus.jettison/com.springsource.org.codehaus.jettison/1.0.1
Or, alternatively, you can use the cool wrap: functionality to wrap a plain-old java jar
servicemix> osgi install -s mvn:org.codehaus.jettison/jettison/1.0.1
Hurray! Now with all the prerequisites in place, I can install my JAX-RS service.
servicemix> osgi install -s mvn:com.progress.pso/simple-restful-service
And now my RESTful service works a treat :)
Tuesday, February 10, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment