I want to use Jersey for implemnting some Java REST services. The default POJO converter JAXB handles JSON objects a bit strange, so I want to use Jackson for converting POJOs with little or less overhead. How would do I tell the J2ME framework to use another converter?
My web.xml looks like this:
<!-- Jersey JAVA REST implementation -->
<servlet>
<servlet-name>Jersey</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>org.foobar.rest.services</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
simply add the jackson JARs and modify the web.xml like this:
<!-- Jersey JAVA REST implementation -->
<servlet>
<servlet-name>Jersey</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>org.foobar.rest.services;org.codehaus.jackson.jaxrs</param-value> <!-- use jackson for JSON -->
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
The required Jackson JARs ( http://jackson.codehaus.org/ ) are:
jackson-core-asl-1.9.10.jar
jackson-core-lgpl-1.9.10.jar
jackson-jaxrs-1.9.10.jar
jackson-mapper-asl-1.9.10.jar
jackson-mapper-lgpl-1.9.10.jar
jackson-mrbean-1.9.10.jar
jackson-smile-1.9.10.jar
jackson-xc-1.9.10.jar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With