How to produce JSON output with Jersey 1.6 using JAXB How to produce JSON output with Jersey 1.6 using JAXB json json

How to produce JSON output with Jersey 1.6 using JAXB


I solved this. All I needed to do was to add jersey-json-1.6.jar library to the project (this is not required part of jersey)


Add the following param to the jersey servlet in web.xml file, this is required for the latest 1.x versions of jersey-servlet.

    <init-param>        <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>        <param-value>true</param-value>    </init-param>


I use Google App Engine and have struggled a lot with this also, if you use jersey-bundle-1.17.jar most of the stuff work until you add

<init-param>    <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>    <param-value>true</param-value></init-param>

you will get a lot of strange messages. This is because you miss some jackson jars.If you go to jersey homepage and download the zip and the bundle. Just drop the bundle and from the zip you need to add the 4 jackson jars in your classpath and you should get everything working without any error.

Adding jackson-jaxrs-1.9.2.jar solve this error below

SEVERE: The registered message body writers compatible with the MIME media type are:application/json ->

Adding jackson-xc-1.9.2.jar solve this warrning below

java.lang.NoClassDefFoundError: org/codehaus/jackson/xc/JaxbAnnotationIntrospector

I hope this helps somebody.