Hello, Could you add a Log endpoint with the showAll=true option? We need to see what the incoming request looks like. Particularly the Content-Type header.
Also please paste your JAX-RS resource class. Are you setting the @Consumes annotation? Another point: getBody(Class) also returns null when the type conversion couldn't be made. This could happen if you have classpath issues (e.g. the class definition duplicated). Raúl. Sent from my iPad > On 28 Mar 2014, at 08:20, bijoy <[email protected]> wrote: > > Hi, > > I'm trying to expose a REST webservice which takes json as input and also > provide response as json. I wanted to package the application as war and to > deploy on external jetty container. I'm facing two problem implementing > this. > > 1. The json object which comes along with REST request is not being mapped > to Exchange body and while accessing the exchange body I'm getting > NullPointerException. But sending json object as response is working fine. > 2. To use JSONProvider I had to include following dependency... > <dependency> > <groupId>org.apache.cxf</groupId> > <artifactId>cxf-bundle-jaxrs</artifactId> > <version>${cxf.version}</version> > </dependency> > But adding above dependency is running internal jetty container(on random > port) on top of external jetty container(running on 8080) instance. I tried > to exclude jetty-* artifacts from the dependency but getting exception while > deploying the app. It seems the modules are inter-dependent so can't be > excluded. > > Any guidance to solve the issues is much appreciated. > > *camel-config.xml* > <import resource="classpath:META-INF/cxf/cxf.xml" /> > <jaxrs:server id="restServer" staticSubresourceResolution="true"> > <jaxrs:serviceBeans> > <ref bean="restServices"/> > </jaxrs:serviceBeans> > <jaxrs:providers> > <ref bean="jsonProvider"/> > </jaxrs:providers> > </jaxrs:server> > > <bean id="jsonProvider" > class="org.apache.cxf.jaxrs.provider.json.JSONProvider"/> > <bean id="processRequest" class="sample.RequestProcessor"/> > > <camel:camelContext id="sampleContext" autoStartup="true" > streamCache="true"> > <camel:route id="httpRequest" startupOrder="2"> > <camel:from > uri="cxfrs://bean://restServer?bindingStyle=SimpleConsumer"/> > <camel:process ref="processRequest"/> > <camel:route/> > <camel:context/> > > *RequestProcessor.java* > public void process(Exchange exchange) throws Exception { > RequestPOJO req = exchange.getIn().getBody(RequestPOJO.class); *//getting > NullPointerException here* > } > > *RequestPOJO.java* > @XmlRootElement(name = "createRequest") > public class RequestPOJO { > > String orderId; > String timeStamp; > public String getOrderId() { > return reRatingOrderId; > } > public void setOrderId(String orderId) { > this.orderId = orderId; > } > public String getTimeStamp() { > return timeStamp; > } > public void setTimeStamp(String timestamp) { > this.timeStamp = timestamp; > } > > *web.xml* > <context-param> > <param-name>contextConfigLocation</param-name> > <param-value>classpath:camel-config.xml</param-value> > </context-param> > > <listener> > > <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> > </listener> > > > <servlet> > <servlet-name>CXFServlet</servlet-name> > <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> > <load-on-startup>1</load-on-startup> > </servlet> > > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474.html > Sent from the Camel - Users mailing list archive at Nabble.com.
