Resteasy client in an OSGi / Eclipse RCP environment
Question
I'm trying to build a client for a Resteasy service in Eclipse. I thought this would be simple - but a lot of the magic that Resteasy does (e.g. looking up annotations on POJOs, loading the Resteasy providers, etc.) seems to be broken by the OSGi class loader. I've spent quite a bit of time resolving the problems with dependencies and buddy policies, but I've come across a stumbling block. I'll describe it, but the best possible solution would be a pre-existing set of OSGi/Eclipse plugins for the resteasy client. Failing that..
could not find writer for content-tyope application/xml type: com.company.Pojo
org.jboss.resteasy.client.ClientRequest.writeRequestBody(ClientRequest:473)
This is resteasy 1.2.1.GA.
Cheers, Rob.
Solution
Ok - managed to sort this in the end, although it's not the most elegant solution.
Steps to take:
- Use Eclipse's create plug-in from JARs wizard
- Import
- jaxrs-api-1.2.1.GA.jar
- resteasy-jaxrs-1.2.1.GA.jar
- resteasy-jaxb-provider-1.2.1.GA.jar
- jaxb-api-2.1.jar
- jaxb-impl-2.1.12.jar
- slf4j-api-1.5.8.jar
- slf4j-simple-1.5.8.jar
- Export the following packages
- javax.ws.rs
- javax.xml.bind.annotation
- org.jboss.resteasy.client (and all subpackages)
- org.jboss.resteasy.plugins.providers
- org.jboss.resteasy.plugins.providers.jaxb
- org.jboss.resteasy.spi
- Add that plug-in as a dependency, and obtain a reference to the client in the usual way
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow