Show Topics
Hide Topics

JAX-RS JSON Example Using RESTEasy


To integrate Jackson with RESTEasy, you just need to include “resteasy-jackson-provider.jar“.


1.Create Dynamic web project in eclipse, convert that into Maven Project


2.Configure pom.xml

To make RESTEasy support JSON mapping, declares “resteasy-jackson-provider.jar“ in Maven pom.xml file.




3.Configure web.xml

In web.xml Disable RESTEasy auto scanning and register your REST service manually, otherwise, you will get Illegal to inject a message body into a singleton into public.JacksonJsonProvider Error



4.Write “UserBo” class

Write “UserBo” class object, Jersey will convert this object into JSON format.



5.Create RESTFul webservice

Annotate the method with @Produces(MediaType.APPLICATION_JSON). Jersey will use Jackson to handle the JSON conversion automatically.



6.Test Webservice directly by using URL / writing webservice client



Download Example Code