Jackson JSON not working with CXF
cxf, jackson, json
Solution
In CXF documentation , you can see where you need to add json provider and include a dependency. But, I still getting errors when I tried to add jackson instead of jettison, after some hours I figured that you need to include one more jackson dependency.
Add JSON provider
<jaxrs:providers>
<bean class="org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider" />
</jaxrs:providers>
Add dependencies
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-xc</artifactId>
<version>1.9.12</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>1.9.12</version>
</dependency>
Problem
The JacksonJsonProvider is not working with CXF. CXF v2.6.0 Jackson v2.1.2 (com.fasterxml.jackson) RESTClient (for testing) I do have the provider configured like below in beans.xml. ``` <bean id="jacksonMapper" class="com.fasterxml.jackson.databind.ObjectMapper"> <property name="dateFormat"> <bean class="java.text.SimpleDateFormat"> <constructor-arg type="java.lang.String" value="yyyy-MM-dd'T'HH:mm:ss.SSSZ"> </constructor-arg> </bean> </property> </bean> <bean id="jacksonProvider" class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"> <property name="mapper" ref="jacksonMapper" /> </bean> ``` in jaxrs:server.....> ``` <jaxrs:providers> <ref bean="jaxbProvider" /> <ref bean="jacksonProvider" /> </jaxrs:providers> </jaxrs:server> ``` The application gets deployed without any issues, it gives good JSON while I give the request as "application/xml" and the response as "application/json". When I try to give JSON in request by setting Content-Type=application/json I'm facing the 500 Internal Server Error The request is getting logged in the log file thru CXF-logging. The request is not at all landing in the service implementation class of my webservice. The JSON in request body is : ``` {"SearchOrdersRequest":{"LoginCredentials":{"AppId":"BookStore","Username":"myuser","Password":"abcd1234","SecurityToken":"Vcvx45YilzX1"},"SearchHeader":{"SearchCategory":"Rep","FilterLogic":"1 AND 2","SearchParams":{"Field":"Order Number (s)","Operator":"EQUALS","Values":"600045335"}}}} ``` Any immediate help is appreciated.