I started to configure my first RESTful app using Apache CXF library and bumped into issue with JAX-RS binding. No matter how I tried to map my classes, I’ve still been getting this error in response instead of JSON data:
No message body writer has been found for response class ArrayList.
The solution was to add dependency on JSON mapping provider since Apache CXF does not include it. It can be XStream or Jackson, I used the last one.
Add dependency for org.codehaus.jackson:jackson-jaxrs to your project
Add JSON provider to Spring context configuration:
<beans xmlns="http://www.springframework.org/schema/beans"...> ... <jaxrs:server id="serviceId"> <jaxrs:serviceBeans> <ref bean="myService"/> </jaxrs:serviceBeans> <jaxrs:providers> <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/> </jaxrs:providers> </jaxrs:server> ... </beans>