We had a similar issue at first and did precisely as Sergey suggests here...
Adding this to the Spring config file for the application .... <jaxrs:providers> <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/> </jaxrs:providers> And also included the @XmlRootElement in the Jaxb-annotated classes we were using.... It solved the problem and we got our JSON response without the messagebody error. In our case, the method was serving to the @GET path. Mark On Feb 1, 2012 7:07 AM, "Sergey Beryozkin" <[email protected]> wrote: > Hi, > On 31/01/12 23:10, cganesan wrote: > >> Hi >> >> I'm trying to exectute an Http POST with following JSON in the request >> body: >> >> { >> "id": "9852654659650" >> } >> >> I expect the JSON to be mapped to the folllowing requestBean Java object >> to >> be injected before the service method is called: >> >> My service method is as follows: >> >> @POST >> @Consumes(MediaType.**APPLICATION_JSON) >> @Path("/test") >> public String test(RequestBean requestBean) { >> return "test"; >> } >> >> I get the error: >> No message body reader has been found for request class RequestBean. >> >> The problem is with maping the inputstream to java object. >> I'm using spring configuation as follows. Do I need to configure >> MessageBodyProvider? If so, could you provide some sample? >> >> <import resource="classpath:META-INF/**cxf/cxf.xml" /> >> <import resource="classpath:META-INF/**cxf/cxf-servlet.xml" /> >> >> <jaxrs:server id="myService" address="/myService"> >> <jaxrs:serviceBeans> >> <ref bean="serviceImpl" /> >> </jaxrs:serviceBeans> >> </jaxrs:server> >> >> <bean id="serviceImpl" class="services.ServiceImpl" /> >> >> Appreciate the help >> >> The default JSONProvider which is Jettison based expects RequestBean be > a JAXB bean, with XmlRootElement, etc. > > You may want to register a Jackson provider (within the jaxrs:providers > section), that should do. Alternatively, try to register a customized CXF > JSONProvider with an 'unmarshalFromJaxbElement' property set to true, that > might help too: > http://cxf.apache.org/docs/**jax-rs-data-bindings.html#JAX-** > RSDataBindings-**HandlingJAXBbeanswithoutXmlRoo**tElementannotations<http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-HandlingJAXBbeanswithoutXmlRootElementannotations> > > Cheers, Sergey > > Thanks >> Chandru >> >> -- >> View this message in context: http://cxf.547215.n5.nabble.** >> com/No-message-body-reader-**has-been-found-for-request-** >> class-tp5445998p5445998.html<http://cxf.547215.n5.nabble.com/No-message-body-reader-has-been-found-for-request-class-tp5445998p5445998.html> >> Sent from the cxf-user mailing list archive at Nabble.com. >> > > > -- > Sergey Beryozkin > > Talend Community Coders > http://coders.talend.com/ > > Blog: http://sberyozkin.blogspot.com >
