Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Sergey Beryozkin <sberyozkin-Re5JQEeQqe8AvxtiuMwx3w <at> public.gmane.org>
Subject: Re: No message body reader has been found for request class
Newsgroups: gmane.comp.apache.cxf.user
Date: Wednesday 1st February 2012 12:07:26 UTC (over 4 years ago)
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?
>
>      
>      
>
>      
>          
>              
>          
>      
>
>      
>
> 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-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
> 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
 
CD: 3ms