You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by bijoy <bi...@gmail.com> on 2014/03/28 09:20:15 UTC

Issues with cxfrs using json

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.

Re: Issues with cxfrs using json -- SOLVED

Posted by bijoy <bi...@gmail.com>.
Adding DeltaRequestPOJO in the method solved my problem and I'm able to parse
and generate json object properly.
I have added jettison library 1.3.5 in order to enable the internal
JSONProvider for cxf which is handling the json object.

As Raul mentioned Camel is useful when we want multiple technology support
under simple roof. My business logic revolves around REST, JMS, File & FTP.
All these component support is readily available in Camel, so camel serves
my purpose.

Thanks everyone for your assistance and bringing this thread towards
closure.

Regards,
Bijoy



--
View this message in context: http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749657.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Issues with cxfrs using json

Posted by Raul Kripalani <ra...@evosent.com>.
It depends on what you're exposing the endpoint for.

If the REST endpoint is a gateway to a business process / service
orchestration / aggregation / scatter-gather / etc. (replace with any kind
of EIP or combination of EIPs), speaking to 10+ systems over different
protocols (SOAP, plain HTTP, JMS, TCP, FTP, File, Mail, AWS SQS, etc.) or
bridging different technologies (MongoDB, JDBC, Salesforce, Facebook,
Twitter, etc.), then it clearly makes sense to use Camel. It is integration
work and that's what Camel is built for.

If your REST endpoint is simply a micro-service with business logic, you
may as well use plain JAX-RS as you propose and inject a ProducerTemplate
if you want to leverage Camel in an ad-hoc manner.

Regards,

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Mon, Mar 31, 2014 at 4:24 PM, akcameluser <ay...@gmail.com>wrote:

> Hi
>
> Just a brief comment. I wonder why people would expose a REST service
> through Camel Route? camel-http (jetty) would do the Job of exposing an
> HTTP
> endpoint. You will have to do the serialization and deserialization of JSON
> yourself, but much simpler way of exposing the endpoint. If you are looking
> for REST service with an elaborate REST API then go for another technology
> like Javax-rs(jersey) or Spring REST. Anyway this is my opinion and I might
> be wrong.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749568.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Issues with cxfrs using json

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 31/03/14 16:24, akcameluser wrote:
> Hi
>
> Just a brief comment. I wonder why people would expose a REST service
> through Camel Route? camel-http (jetty) would do the Job of exposing an HTTP
> endpoint. You will have to do the serialization and deserialization of JSON
> yourself, but much simpler way of exposing the endpoint. If you are looking
> for REST service with an elaborate REST API then go for another technology
> like Javax-rs(jersey) or Spring REST. Anyway this is my opinion and I might
> be wrong.
You are obviously off-topic - the thread is about using CXFRS component.
That said, AFAIK I've no problems with yourself or other users using the 
alternative approaches, Camel has many options, but nether will I go and 
tell them why do you use that other technology instead of CXFRS, because 
I'd consider it being a bit off topic to say the least

Sergey

>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749568.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


Re: Issues with cxfrs using json

Posted by akcameluser <ay...@gmail.com>.
Hi 

Just a brief comment. I wonder why people would expose a REST service
through Camel Route? camel-http (jetty) would do the Job of exposing an HTTP
endpoint. You will have to do the serialization and deserialization of JSON
yourself, but much simpler way of exposing the endpoint. If you are looking
for REST service with an elaborate REST API then go for another technology
like Javax-rs(jersey) or Spring REST. Anyway this is my opinion and I might
be wrong.



--
View this message in context: http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749568.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Issues with cxfrs using json

Posted by Raul Kripalani <ra...@evosent.com>.
Exactly. Currently you are telling Camel that you want a String. That's why
you're not getting a POJO.

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Mon, Mar 31, 2014 at 9:36 AM, Sergey Beryozkin <sb...@gmail.com>wrote:

> Hi,
> If you need CXF help converting the data into POJO then add
> DeltaRequestPOJO into the signature, instead of String/InputStream.
> This will work assuming a JAX-RS JSON provider is registered with the
> endpoint.
> Otherwise, if you prefer it done at the Camel level, then I guess you will
> need to set up Camel Data Format...
>
> Cheers, Sergey
>
> On 31/03/14 07:22, bijoy wrote:
>
>> Hi Sergey,
>>
>> Adding String and InputStream in the method signature making json data
>> available to exchange body but camel is not able to convert the json into
>> pojo. I'm using SimpleConsumer binding. I guess the problem is with
>> binding,
>> any idea?
>>
>> *camel-config.xml*
>> <camel:route id="httpRequest">
>>             <camel:from
>> uri="cxfrs://bean://restServer?bindingStyle=SimpleConsumer"/>
>>             <camel:to uri="log:?showAll=true"/>
>>             <camel:process ref="validateRequest"/>
>> </camel:route>
>>
>> *ValidateProcessor.java*
>> public void process(Exchange exchange) throws Exception {
>> String message = exchange.getIn().getBody(String.class);
>> System.out.println("JSON Message:"+message); //*proper json is displayed>*
>> DeltaRequestPOJO deltaReq =
>> exchange.getIn().getBody(DeltaRequestPOJO.class);
>> if (!deltaReq.getOrderId().isEmpty() && !deltaReq.getTimeStamp().
>> isEmpty())
>> // *getting null pointer here*
>>                         {
>>                                 //some logic
>>                         }
>>
>> *DeltaRequestPOJO.java*
>> @XmlRootElement(name = "createDeltaRequest")
>> public class DeltaRequestPOJO {
>>
>>         String orderId;
>>         String timeStamp;
>>          // then getters and setters
>>
>> *RestServices.java*
>>     @POST
>>      @Consumes("application/json")
>>      @Produces("application/json")
>>      @Path("/delta")
>>      public Response createDelta(String jsonData) {
>>          return null;
>>      }
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.
>> com/Issues-with-cxfrs-using-json-tp5749474p5749552.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>

Re: Issues with cxfrs using json

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi,
If you need CXF help converting the data into POJO then add
DeltaRequestPOJO into the signature, instead of String/InputStream.
This will work assuming a JAX-RS JSON provider is registered with the 
endpoint.
Otherwise, if you prefer it done at the Camel level, then I guess you 
will need to set up Camel Data Format...

Cheers, Sergey
On 31/03/14 07:22, bijoy wrote:
> Hi Sergey,
>
> Adding String and InputStream in the method signature making json data
> available to exchange body but camel is not able to convert the json into
> pojo. I'm using SimpleConsumer binding. I guess the problem is with binding,
> any idea?
>
> *camel-config.xml*
> <camel:route id="httpRequest">
>             <camel:from
> uri="cxfrs://bean://restServer?bindingStyle=SimpleConsumer"/>
>             <camel:to uri="log:?showAll=true"/>
>             <camel:process ref="validateRequest"/>
> </camel:route>
>
> *ValidateProcessor.java*
> public void process(Exchange exchange) throws Exception {
> String message = exchange.getIn().getBody(String.class);
> System.out.println("JSON Message:"+message); //*proper json is displayed>*
> DeltaRequestPOJO deltaReq =
> exchange.getIn().getBody(DeltaRequestPOJO.class);
> if (!deltaReq.getOrderId().isEmpty() && !deltaReq.getTimeStamp().isEmpty())
> // *getting null pointer here*
> 			{
> 				//some logic
> 			}
>
> *DeltaRequestPOJO.java*
> @XmlRootElement(name = "createDeltaRequest")
> public class DeltaRequestPOJO {
> 	
> 	String orderId;
> 	String timeStamp;
>          // then getters and setters
>
> *RestServices.java*
>     @POST
>      @Consumes("application/json")
>      @Produces("application/json")
>      @Path("/delta")
>      public Response createDelta(String jsonData) {
>          return null;
>      }
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749552.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: Issues with cxfrs using json

Posted by bijoy <bi...@gmail.com>.
Hi Sergey,

Adding String and InputStream in the method signature making json data
available to exchange body but camel is not able to convert the json into
pojo. I'm using SimpleConsumer binding. I guess the problem is with binding,
any idea?

*camel-config.xml*
<camel:route id="httpRequest">
           <camel:from
uri="cxfrs://bean://restServer?bindingStyle=SimpleConsumer"/>
           <camel:to uri="log:?showAll=true"/>
           <camel:process ref="validateRequest"/>     
</camel:route>

*ValidateProcessor.java*
public void process(Exchange exchange) throws Exception {
String message = exchange.getIn().getBody(String.class);
System.out.println("JSON Message:"+message); //*proper json is displayed>*
DeltaRequestPOJO deltaReq =
exchange.getIn().getBody(DeltaRequestPOJO.class);
if (!deltaReq.getOrderId().isEmpty() && !deltaReq.getTimeStamp().isEmpty())
// *getting null pointer here*
			{
				//some logic
			}

*DeltaRequestPOJO.java*
@XmlRootElement(name = "createDeltaRequest")
public class DeltaRequestPOJO {
	
	String orderId;
	String timeStamp;
        // then getters and setters

*RestServices.java*
   @POST
    @Consumes("application/json")
    @Produces("application/json")
    @Path("/delta")
    public Response createDelta(String jsonData) {
        return null;
    }



--
View this message in context: http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749552.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Issues with cxfrs using json

Posted by Sergey Beryozkin <sb...@gmail.com>.
You can simply add InputStream into the signature, and it should become 
available, as far as I recall it will be wrapped in CXF message content 
list, SimpleBinding can make it more easier to access

Give it a try please
Sergey
On 28/03/14 14:38, bijoy wrote:
> Yes Sergey, what you pointed is right.
>
> I was trying to parse the CxfXmlMessage object which resides in the header
> and that itself was null. So, the problem is with service definition
> signature.
>
> Can you please suggest how to pass the input json to request body?
>
> Thanks a lot!
>
> Regards,
> Bijoy
>
>
> On Fri, Mar 28, 2014 at 7:51 PM, Sergey Beryozkin-3 [via Camel] <
> ml-node+s465427n5749504h54@n5.nabble.com> wrote:
>
>> Hi
>>
>> Right I've just spotted it,
>>
>> @Path("/orders/{orderId}")
>> public class RestServices {
>>       @POST
>>       @Consumes("application/json")
>>       @Produces("application/json")
>>       @Path("/delta")
>>       public Response createDelta() {
>>              return null;
>>       }
>> }
>>
>> You don't have a parameter representing the request body, so what
>> exactly the runtime can set as the exchange body in this case ?
>>
>> The input stream representing the JSON sequence should be accessible
>> though, can you access InputStream or if no actual read has occurred
>> then InputStream is supposed to represent the body ?
>>
>> Thanks, Sergey
>>
>> On 28/03/14 12:13, bijoy wrote:
>>
>>> Sergey,
>>>
>>> Thanks for your assistance!
>>>
>>> I have added jettison dependency but still the same exception was being
>>> thrown. The I made following changes to configuration file which did not
>>> throw any startup errors.
>>>
>>> *camel-config.xml*
>>> <cxf:rsServer id="restServer" address=""
>>>
>>> serviceClass="com.ericsson.bss.edm.rerating.stub.ReratingServices"
>>>                  loggingFeatureEnabled="true" />
>>> <import resource="classpath:META-INF/cxf/cxf.xml" />
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> This configuration works but still input json is not mapped to exchange
>>> body, though output pojo to json mapping is working and being sent to
>> client
>>> properly. Following is message history...
>>>
>>>
>>> Message History
>>>
>> ---------------------------------------------------------------------------------------------------------------------------------------
>>
>>> RouteId              ProcessorId          Processor
>>> Elapsed (ms)
>>> [httpRequest       ] [httpRequest       ]
>>> [cxfrs://bean://restServer?bindingStyle=SimpleConsumer
>>> ] [        62]
>>> [httpRequest       ] [to1               ] [log:?showAll=true
>>> ] [         6]
>>> [httpRequest       ] [process3          ] [ref:processRequest
>>> ] [         6]
>>>
>>> Exchange
>>>
>> ---------------------------------------------------------------------------------------------------------------------------------------
>>
>>> Exchange[
>>>           Id                  ID-PG85238-43050-1395997134260-0-2
>>>           ExchangePattern     InOut
>>>           Headers
>>> {breadcrumbId=ID-PG85238-43050-1395997134260-0-1,
>>> CamelAcceptContentType=*/*,
>>> CamelCxfMessage=org.apache.cxf.message.XMLMessage@84f9cd67,
>>>
>> CamelCxfRsOperationResourceInfoStack=[org.apache.cxf.jaxrs.model.MethodInvocationInfo@5ce5ef67],
>>
>>> CamelCxfRsResponseClass=class javax.ws.rs.core.Response,
>>> CamelCxfRsResponseGenericType=class javax.ws.rs.core.Response,
>>> CamelHttpCharacterEncoding=ISO-8859-1, CamelHttpMethod=POST,
>>> CamelHttpPath=/orders/4001/delta, CamelHttpUri=/orders/4001/delta,
>>> CamelRedelivered=false, CamelRedeliveryCounter=0, connection=keep-alive,
>>> Content-Length=100, content-type=application/json, Host=localhost:42107,
>>> operationName=createDelta, orderId=4001}
>>>           BodyType            org.apache.cxf.message.MessageContentsList
>>>           Body                []
>>> ]
>>>
>>> Stacktrace
>>>
>> ---------------------------------------------------------------------------------------------------------------------------------------
>>
>>> java.lang.NullPointerException: null
>>>
>>>
>>>
>>> Not sure why input json in not being mapped to pojo. One thing,
>>> CamelCxfMessage is referring to XMLMessage even though the content-type
>> is
>>> application/json. Not sure if this should help in tracing the problem.
>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context:
>> http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749498.html
>>
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>
>>
>>
>> ------------------------------
>>   If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749504.html
>>   To unsubscribe from Issues with cxfrs using json, click here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5749474&code=Ymlqb3kuY2hhdWRodXJ5QGdtYWlsLmNvbXw1NzQ5NDc0fC0xODQ1MjQzMTU1>
>> .
>> NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749506.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



Re: Issues with cxfrs using json

Posted by bijoy <bi...@gmail.com>.
Yes Sergey, what you pointed is right.

I was trying to parse the CxfXmlMessage object which resides in the header
and that itself was null. So, the problem is with service definition
signature.

Can you please suggest how to pass the input json to request body?

Thanks a lot!

Regards,
Bijoy


On Fri, Mar 28, 2014 at 7:51 PM, Sergey Beryozkin-3 [via Camel] <
ml-node+s465427n5749504h54@n5.nabble.com> wrote:

> Hi
>
> Right I've just spotted it,
>
> @Path("/orders/{orderId}")
> public class RestServices {
>      @POST
>      @Consumes("application/json")
>      @Produces("application/json")
>      @Path("/delta")
>      public Response createDelta() {
>             return null;
>      }
> }
>
> You don't have a parameter representing the request body, so what
> exactly the runtime can set as the exchange body in this case ?
>
> The input stream representing the JSON sequence should be accessible
> though, can you access InputStream or if no actual read has occurred
> then InputStream is supposed to represent the body ?
>
> Thanks, Sergey
>
> On 28/03/14 12:13, bijoy wrote:
>
> > Sergey,
> >
> > Thanks for your assistance!
> >
> > I have added jettison dependency but still the same exception was being
> > thrown. The I made following changes to configuration file which did not
> > throw any startup errors.
> >
> > *camel-config.xml*
> > <cxf:rsServer id="restServer" address=""
> >
> > serviceClass="com.ericsson.bss.edm.rerating.stub.ReratingServices"
> >                 loggingFeatureEnabled="true" />
> > <import resource="classpath:META-INF/cxf/cxf.xml" />
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > This configuration works but still input json is not mapped to exchange
> > body, though output pojo to json mapping is working and being sent to
> client
> > properly. Following is message history...
> >
> >
> > Message History
> >
> ---------------------------------------------------------------------------------------------------------------------------------------
>
> > RouteId              ProcessorId          Processor
> > Elapsed (ms)
> > [httpRequest       ] [httpRequest       ]
> > [cxfrs://bean://restServer?bindingStyle=SimpleConsumer
> > ] [        62]
> > [httpRequest       ] [to1               ] [log:?showAll=true
> > ] [         6]
> > [httpRequest       ] [process3          ] [ref:processRequest
> > ] [         6]
> >
> > Exchange
> >
> ---------------------------------------------------------------------------------------------------------------------------------------
>
> > Exchange[
> >          Id                  ID-PG85238-43050-1395997134260-0-2
> >          ExchangePattern     InOut
> >          Headers
> > {breadcrumbId=ID-PG85238-43050-1395997134260-0-1,
> > CamelAcceptContentType=*/*,
> > CamelCxfMessage=org.apache.cxf.message.XMLMessage@84f9cd67,
> >
> CamelCxfRsOperationResourceInfoStack=[org.apache.cxf.jaxrs.model.MethodInvocationInfo@5ce5ef67],
>
> > CamelCxfRsResponseClass=class javax.ws.rs.core.Response,
> > CamelCxfRsResponseGenericType=class javax.ws.rs.core.Response,
> > CamelHttpCharacterEncoding=ISO-8859-1, CamelHttpMethod=POST,
> > CamelHttpPath=/orders/4001/delta, CamelHttpUri=/orders/4001/delta,
> > CamelRedelivered=false, CamelRedeliveryCounter=0, connection=keep-alive,
> > Content-Length=100, content-type=application/json, Host=localhost:42107,
> > operationName=createDelta, orderId=4001}
> >          BodyType            org.apache.cxf.message.MessageContentsList
> >          Body                []
> > ]
> >
> > Stacktrace
> >
> ---------------------------------------------------------------------------------------------------------------------------------------
>
> > java.lang.NullPointerException: null
> >
> >
> >
> > Not sure why input json in not being mapped to pojo. One thing,
> > CamelCxfMessage is referring to XMLMessage even though the content-type
> is
> > application/json. Not sure if this should help in tracing the problem.
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749498.html
>
> > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749504.html
>  To unsubscribe from Issues with cxfrs using json, click here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5749474&code=Ymlqb3kuY2hhdWRodXJ5QGdtYWlsLmNvbXw1NzQ5NDc0fC0xODQ1MjQzMTU1>
> .
> NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749506.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Issues with cxfrs using json

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

Right I've just spotted it,

@Path("/orders/{orderId}")
public class RestServices {
     @POST
     @Consumes("application/json")
     @Produces("application/json")
     @Path("/delta")
     public Response createDelta() {
            return null;
     }
}

You don't have a parameter representing the request body, so what 
exactly the runtime can set as the exchange body in this case ?

The input stream representing the JSON sequence should be accessible 
though, can you access InputStream or if no actual read has occurred 
then InputStream is supposed to represent the body ?

Thanks, Sergey

On 28/03/14 12:13, bijoy wrote:
> Sergey,
>
> Thanks for your assistance!
>
> I have added jettison dependency but still the same exception was being
> thrown. The I made following changes to configuration file which did not
> throw any startup errors.
>
> *camel-config.xml*
> <cxf:rsServer id="restServer" address=""
>
> serviceClass="com.ericsson.bss.edm.rerating.stub.ReratingServices"
>                 loggingFeatureEnabled="true" />
> <import resource="classpath:META-INF/cxf/cxf.xml" />
>
>
>
>
>
>
>
>
>
>
>
>
> This configuration works but still input json is not mapped to exchange
> body, though output pojo to json mapping is working and being sent to client
> properly. Following is message history...
>
>
> Message History
> ---------------------------------------------------------------------------------------------------------------------------------------
> RouteId              ProcessorId          Processor
> Elapsed (ms)
> [httpRequest       ] [httpRequest       ]
> [cxfrs://bean://restServer?bindingStyle=SimpleConsumer
> ] [        62]
> [httpRequest       ] [to1               ] [log:?showAll=true
> ] [         6]
> [httpRequest       ] [process3          ] [ref:processRequest
> ] [         6]
>
> Exchange
> ---------------------------------------------------------------------------------------------------------------------------------------
> Exchange[
>          Id                  ID-PG85238-43050-1395997134260-0-2
>          ExchangePattern     InOut
>          Headers
> {breadcrumbId=ID-PG85238-43050-1395997134260-0-1,
> CamelAcceptContentType=*/*,
> CamelCxfMessage=org.apache.cxf.message.XMLMessage@84f9cd67,
> CamelCxfRsOperationResourceInfoStack=[org.apache.cxf.jaxrs.model.MethodInvocationInfo@5ce5ef67],
> CamelCxfRsResponseClass=class javax.ws.rs.core.Response,
> CamelCxfRsResponseGenericType=class javax.ws.rs.core.Response,
> CamelHttpCharacterEncoding=ISO-8859-1, CamelHttpMethod=POST,
> CamelHttpPath=/orders/4001/delta, CamelHttpUri=/orders/4001/delta,
> CamelRedelivered=false, CamelRedeliveryCounter=0, connection=keep-alive,
> Content-Length=100, content-type=application/json, Host=localhost:42107,
> operationName=createDelta, orderId=4001}
>          BodyType            org.apache.cxf.message.MessageContentsList
>          Body                []
> ]
>
> Stacktrace
> ---------------------------------------------------------------------------------------------------------------------------------------
> java.lang.NullPointerException: null
>
>
>
> Not sure why input json in not being mapped to pojo. One thing,
> CamelCxfMessage is referring to XMLMessage even though the content-type is
> application/json. Not sure if this should help in tracing the problem.
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749498.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


Re: Issues with cxfrs using json

Posted by bijoy <bi...@gmail.com>.
Sergey,

Thanks for your assistance!

I have added jettison dependency but still the same exception was being
thrown. The I made following changes to configuration file which did not
throw any startup errors. 

*camel-config.xml*
<cxf:rsServer id="restServer" address=""
              
serviceClass="com.ericsson.bss.edm.rerating.stub.ReratingServices" 
               loggingFeatureEnabled="true" />
<import resource="classpath:META-INF/cxf/cxf.xml" />   
      











This configuration works but still input json is not mapped to exchange
body, though output pojo to json mapping is working and being sent to client
properly. Following is message history... 


Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                                       
Elapsed (ms)
[httpRequest       ] [httpRequest       ]
[cxfrs://bean://restServer?bindingStyle=SimpleConsumer                        
] [        62]
[httpRequest       ] [to1               ] [log:?showAll=true                                                            
] [         6]
[httpRequest       ] [process3          ] [ref:processRequest                                                          
] [         6]

Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange[
        Id                  ID-PG85238-43050-1395997134260-0-2
        ExchangePattern     InOut
        Headers            
{breadcrumbId=ID-PG85238-43050-1395997134260-0-1,
CamelAcceptContentType=*/*,
CamelCxfMessage=org.apache.cxf.message.XMLMessage@84f9cd67,
CamelCxfRsOperationResourceInfoStack=[org.apache.cxf.jaxrs.model.MethodInvocationInfo@5ce5ef67],
CamelCxfRsResponseClass=class javax.ws.rs.core.Response,
CamelCxfRsResponseGenericType=class javax.ws.rs.core.Response,
CamelHttpCharacterEncoding=ISO-8859-1, CamelHttpMethod=POST,
CamelHttpPath=/orders/4001/delta, CamelHttpUri=/orders/4001/delta,
CamelRedelivered=false, CamelRedeliveryCounter=0, connection=keep-alive,
Content-Length=100, content-type=application/json, Host=localhost:42107,
operationName=createDelta, orderId=4001}
        BodyType            org.apache.cxf.message.MessageContentsList
        Body                []
]

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
java.lang.NullPointerException: null 



Not sure why input json in not being mapped to pojo. One thing,
CamelCxfMessage is referring to XMLMessage even though the content-type is
application/json. Not sure if this should help in tracing the problem.





--
View this message in context: http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749498.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Issues with cxfrs using json

Posted by bijoy <bi...@gmail.com>.
Main changes are:
Goal 6 - Definition and Rating Scale (Just replace it with new one)
Goal 7 - Definition changed (Just replace it with new one)
Goal 8 and 10 - Rating Scale is changed (Just replace it with new one)



   <import resource="classpath:META-INF/cxf/cxf.xml" />   
      











This configuration works but still input json is not mapped to exchange
body, though output pojo to json mapping is working and being sent to client
properly. Following is message history... 


Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                                       
Elapsed (ms)
[httpRequest       ] [httpRequest       ]
[cxfrs://bean://restServer?bindingStyle=SimpleConsumer                        
] [        62]
[httpRequest       ] [to1               ] [log:?showAll=true                                                            
] [         6]
[httpRequest       ] [process3          ] [ref:processRequest                                                          
] [         6]

Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange[
        Id                  ID-PG85238-43050-1395997134260-0-2
        ExchangePattern     InOut
        Headers            
{breadcrumbId=ID-PG85238-43050-1395997134260-0-1,
CamelAcceptContentType=*/*,
CamelCxfMessage=org.apache.cxf.message.XMLMessage@84f9cd67,
CamelCxfRsOperationResourceInfoStack=[org.apache.cxf.jaxrs.model.MethodInvocationInfo@5ce5ef67],
CamelCxfRsResponseClass=class javax.ws.rs.core.Response,
CamelCxfRsResponseGenericType=class javax.ws.rs.core.Response,
CamelHttpCharacterEncoding=ISO-8859-1, CamelHttpMethod=POST,
CamelHttpPath=/orders/4001/delta, CamelHttpUri=/orders/4001/delta,
CamelRedelivered=false, CamelRedeliveryCounter=0, connection=keep-alive,
Content-Length=100, content-type=application/json, Host=localhost:42107,
operationName=createDelta, orderId=4001}
        BodyType            org.apache.cxf.message.MessageContentsList
        Body                []
]

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
java.lang.NullPointerException: null 



Not sure why input json in not being mapped to pojo. One thing,
CamelCxfMessage is referring to XMLMessage even though the content-type is
application/json. Not sure if this should help in tracing the problem.




--
View this message in context: http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749497.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Issues with cxfrs using json

Posted by Sergey Beryozkin <sb...@gmail.com>.
I should've mentioned that

<dependency>
             <groupId>org.codehaus.jettison</groupId>
             <artifactId>jettison</artifactId>
             <version>1.3.5</version>
</dependency>

needs to be added too, the CXF module is very thin, has many optional 
providers support, hence the Jettison dep is optional there. You can 
also use Jackson, though with CXF 2.7.7 it probably has to be Jackson 
1.9.0...

HTH, Sergey

On 28/03/14 10:49, bijoy wrote:
> Hi
>
> I'm using cxf 2.7.7.
>
> I have removed cxf-bundle-jaxrs from dependency and added
> cxf-rt-rs-extension-providers. I have cxf.xml in classpath.
> <import resource="classpath:META-INF/cxf/cxf.xml" />
>
> But getting following exception...
>
> 2014-03-28 15:50:26.195:WARN:oejw.WebAppContext:Scanner-0: Failed startup of
> context
> o.e.j.w.WebAppContext@2b30630e{/edm,file:/tmp/jetty-0.0.0.0-8080-edm.war-_edm-any-8012008925635602988.dir/webapp/,STARTING}{/edm.war}
> org.apache.camel.RuntimeCamelException:
> org.apache.cxf.service.factory.ServiceConstructionException
> 	at
> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1352)
> 	at
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:120)
> 	at
> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:301)
> 	at
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:96)
> 	at
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
> 	at
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:948)
> 	at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
> 	at
> org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
> 	at
> org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
> 	at
> org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
> 	at
> org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:799)
> 	at
> org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:446)
> 	at
> org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:791)
> 	at
> org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:296)
> 	at
> org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1347)
> 	at
> org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:743)
> 	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
> 	at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
> 	at
> org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:117)
> 	at
> org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:281)
> 	at
> org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:213)
> 	at
> org.eclipse.jetty.util.component.ContainerLifeCycle.updateBeans(ContainerLifeCycle.java:763)
> 	at
> org.eclipse.jetty.server.handler.HandlerCollection.setHandlers(HandlerCollection.java:89)
> 	at
> org.eclipse.jetty.server.handler.ContextHandlerCollection.setHandlers(ContextHandlerCollection.java:144)
> 	at
> org.eclipse.jetty.server.handler.HandlerCollection.addHandler(HandlerCollection.java:155)
> 	at
> org.eclipse.jetty.deploy.bindings.StandardDeployer.processBinding(StandardDeployer.java:41)
> 	at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
> 	at
> org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:498)
> 	at
> org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
> 	at
> org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileChanged(ScanningAppProvider.java:198)
> 	at
> org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileChanged(ScanningAppProvider.java:70)
> 	at org.eclipse.jetty.util.Scanner.reportChange(Scanner.java:659)
> 	at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:531)
> 	at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
> 	at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:329)
> 	at java.util.TimerThread.mainLoop(Timer.java:555)
> 	at java.util.TimerThread.run(Timer.java:505)
> Caused by:
> org.apache.cxf.service.factory.ServiceConstructionException
> 	at
> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:209)
> 	at
> org.apache.camel.component.cxf.jaxrs.CxfRsConsumer.<init>(CxfRsConsumer.java:38)
> 	at
> org.apache.camel.component.cxf.jaxrs.CxfRsEndpoint.createConsumer(CxfRsEndpoint.java:140)
> 	at
> org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenConsumerRoute.java:65)
> 	at
> org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java:80)
> 	at org.apache.camel.impl.RouteService.warmUp(RouteService.java:134)
> 	at
> org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:2109)
> 	at
> org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:2039)
> 	at
> org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1827)
> 	at
> org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1699)
> 	at
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1544)
> 	at
> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:179)
> 	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
> 	at
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1512)
> 	at
> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:228)
> 	at
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:118)
> 	at
> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:301)
> 	at
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:96)
> 	at
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
> 	at
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:948)
> 	at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
> 	at
> org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
> 	at
> org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
> 	at
> org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
> 	at
> org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:799)
> 	at
> org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:446)
> 	at
> org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:791)
> 	at
> org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:296)
> 	at
> org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1347)
> 	at
> org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:743)
> 	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
> 	at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
> 	at
> org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:117)
> 	at
> org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:281)
> 	at
> org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:213)
> 	at
> org.eclipse.jetty.util.component.ContainerLifeCycle.updateBeans(ContainerLifeCycle.java:763)
> 	at
> org.eclipse.jetty.server.handler.HandlerCollection.setHandlers(HandlerCollection.java:89)
> 	at
> org.eclipse.jetty.server.handler.ContextHandlerCollection.setHandlers(ContextHandlerCollection.java:144)
> 	at
> org.eclipse.jetty.server.handler.HandlerCollection.addHandler(HandlerCollection.java:155)
> 	at
> org.eclipse.jetty.deploy.bindings.StandardDeployer.processBinding(StandardDeployer.java:41)
> 	at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
> 	at
> org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:498)
> 	at
> org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
> 	at
> org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileChanged(ScanningAppProvider.java:198)
> 	at
> org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileChanged(ScanningAppProvider.java:70)
> 	at org.eclipse.jetty.util.Scanner.reportChange(Scanner.java:659)
> 	at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:531)
> 	at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
> 	at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:329)
> 	at java.util.TimerThread.mainLoop(Timer.java:555)
> 	at java.util.TimerThread.run(Timer.java:505)
> Caused by:
> java.lang.NullPointerException
> 	at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:333)
> 	at
> java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:1175)
> 	at
> org.apache.cxf.transport.http.DestinationRegistryImpl.removeDestination(DestinationRegistryImpl.java:62)
> 	at
> org.apache.cxf.transport.http.AbstractHTTPDestination.shutdown(AbstractHTTPDestination.java:886)
> 	at org.apache.cxf.endpoint.ServerImpl.destroy(ServerImpl.java:183)
> 	at
> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:198)
> 	at
> org.apache.camel.component.cxf.jaxrs.CxfRsConsumer.<init>(CxfRsConsumer.java:38)
> 	at
> org.apache.camel.component.cxf.jaxrs.CxfRsEndpoint.createConsumer(CxfRsEndpoint.java:140)
> 	at
> org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenConsumerRoute.java:65)
> 	at
> org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java:80)
> 	at org.apache.camel.impl.RouteService.warmUp(RouteService.java:134)
> 	at
> org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:2109)
> 	at
> org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:2039)
> 	at
> org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1827)
> 	at
> org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1699)
> 	at
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1544)
> 	at
> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:179)
> 	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
> 	at
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1512)
> 	at
> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:228)
> 	at
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:118)
> 	at
> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:301)
> 	at
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:96)
> 	at
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
> 	at
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:948)
> 	at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
> 	at
> org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
> 	at
> org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
> 	at
> org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
> 	at
> org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:799)
> 	at
> org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:446)
> 	at
> org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:791)
> 	at
> org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:296)
> 	at
> org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1347)
> 	at
> org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:743)
> 	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
> 	at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
> 	at
> org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:117)
> 	at
> org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:281)
> 	at
> org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:213)
> 	at
> org.eclipse.jetty.util.component.ContainerLifeCycle.updateBeans(ContainerLifeCycle.java:763)
> 	at
> org.eclipse.jetty.server.handler.HandlerCollection.setHandlers(HandlerCollection.java:89)
> 	at
> org.eclipse.jetty.server.handler.ContextHandlerCollection.setHandlers(ContextHandlerCollection.java:144)
> 	at
> org.eclipse.jetty.server.handler.HandlerCollection.addHandler(HandlerCollection.java:155)
> 	at
> org.eclipse.jetty.deploy.bindings.StandardDeployer.processBinding(StandardDeployer.java:41)
> 	at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
> 	at
> org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:498)
> 	at
> org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
> 	at
> org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileChanged(ScanningAppProvider.java:198)
> 	at
> org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileChanged(ScanningAppProvider.java:70)
> 	at org.eclipse.jetty.util.Scanner.reportChange(Scanner.java:659)
> 	at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:531)
> 	at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
> 	at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:329)
> 	at java.util.TimerThread.mainLoop(Timer.java:555)
> 	at java.util.TimerThread.run(Timer.java:505)
> 2014-03-28 15:55:02.967:INFO:oejwc.WebSocketClient:Scanner-0: Stopped
> org.eclipse.jetty.websocket.client.WebSocketClient@1384634e
> 2014-03-28 15:55:02.979:INFO:edm:Scanner-0: Closing Spring root
> WebApplicationContext
> 278372 [Scanner-0] INFO
> org.springframework.web.context.support.XmlWebApplicationContext  - Closing
> Root WebApplicationContext: startup date [Fri Mar 28 15:50:24 IST 2014];
> root of context hierarchy
> 278373 [Scanner-0] WARN
> org.springframework.web.context.support.XmlWebApplicationContext  -
> Exception thrown from ApplicationListener handling ContextClosedEvent
> java.lang.NullPointerException
> 	at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:333)
> 	at
> java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:1175)
> 	at
> org.apache.cxf.transport.http.DestinationRegistryImpl.removeDestination(DestinationRegistryImpl.java:62)
> 	at
> org.apache.cxf.transport.http.AbstractHTTPDestination.deactivate(AbstractHTTPDestination.java:877)
> 	at
> org.apache.cxf.transport.AbstractObservable.setMessageObserver(AbstractObservable.java:58)
> 	at org.apache.cxf.endpoint.ServerImpl.stop(ServerImpl.java:176)
> 	at org.apache.cxf.endpoint.ServerImpl.destroy(ServerImpl.java:181)
> 	at
> org.apache.cxf.bus.managers.ServerRegistryImpl.preShutdown(ServerRegistryImpl.java:90)
> 	at
> org.apache.cxf.bus.managers.CXFBusLifeCycleManager.preShutdown(CXFBusLifeCycleManager.java:95)
> 	at
> org.apache.cxf.bus.managers.CXFBusLifeCycleManager.postShutdown(CXFBusLifeCycleManager.java:102)
> 	at
> org.apache.cxf.bus.spring.SpringBus.onApplicationEvent(SpringBus.java:113)
> 	at
> org.apache.cxf.bus.spring.SpringBus$1.onApplicationEvent(SpringBus.java:64)
> 	at
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:96)
> 	at
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
> 	at
> org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1049)
> 	at
> org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
> 	at
> org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:559)
> 	at
> org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)
> 	at
> org.eclipse.jetty.server.handler.ContextHandler.callContextDestroyed(ContextHandler.java:806)
> 	at
> org.eclipse.jetty.servlet.ServletContextHandler.callContextDestroyed(ServletContextHandler.java:459)
> 	at
> org.eclipse.jetty.server.handler.ContextHandler.doStop(ContextHandler.java:840)
> 	at
> org.eclipse.jetty.servlet.ServletContextHandler.doStop(ServletContextHandler.java:217)
> 	at org.eclipse.jetty.webapp.WebAppContext.doStop(WebAppContext.java:516)
> 	at
> org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:90)
> 	at
> org.eclipse.jetty.deploy.bindings.StandardStopper.processBinding(StandardStopper.java:44)
> 	at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
> 	at
> org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:498)
> 	at
> org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:458)
> 	at
> org.eclipse.jetty.deploy.DeploymentManager.removeApp(DeploymentManager.java:409)
> 	at
> org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileRemoved(ScanningAppProvider.java:209)
> 	at
> org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileRemoved(ScanningAppProvider.java:76)
> 	at org.eclipse.jetty.util.Scanner.reportRemoval(Scanner.java:632)
> 	at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:534)
> 	at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
> 	at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:329)
> 	at java.util.TimerThread.mainLoop(Timer.java:555)
> 	at java.util.TimerThread.run(Timer.java:505)
>
>
> Any idea?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749495.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



Re: Issues with cxfrs using json

Posted by bijoy <bi...@gmail.com>.
Hi

I'm using cxf 2.7.7.

I have removed cxf-bundle-jaxrs from dependency and added
cxf-rt-rs-extension-providers. I have cxf.xml in classpath.
<import resource="classpath:META-INF/cxf/cxf.xml" />   

But getting following exception...

2014-03-28 15:50:26.195:WARN:oejw.WebAppContext:Scanner-0: Failed startup of
context
o.e.j.w.WebAppContext@2b30630e{/edm,file:/tmp/jetty-0.0.0.0-8080-edm.war-_edm-any-8012008925635602988.dir/webapp/,STARTING}{/edm.war}
org.apache.camel.RuntimeCamelException:
org.apache.cxf.service.factory.ServiceConstructionException
	at
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1352)
	at
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:120)
	at
org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:301)
	at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:96)
	at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
	at
org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:948)
	at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
	at
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
	at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
	at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
	at
org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:799)
	at
org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:446)
	at
org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:791)
	at
org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:296)
	at
org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1347)
	at
org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:743)
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
	at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
	at
org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:117)
	at
org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:281)
	at
org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:213)
	at
org.eclipse.jetty.util.component.ContainerLifeCycle.updateBeans(ContainerLifeCycle.java:763)
	at
org.eclipse.jetty.server.handler.HandlerCollection.setHandlers(HandlerCollection.java:89)
	at
org.eclipse.jetty.server.handler.ContextHandlerCollection.setHandlers(ContextHandlerCollection.java:144)
	at
org.eclipse.jetty.server.handler.HandlerCollection.addHandler(HandlerCollection.java:155)
	at
org.eclipse.jetty.deploy.bindings.StandardDeployer.processBinding(StandardDeployer.java:41)
	at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
	at
org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:498)
	at
org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
	at
org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileChanged(ScanningAppProvider.java:198)
	at
org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileChanged(ScanningAppProvider.java:70)
	at org.eclipse.jetty.util.Scanner.reportChange(Scanner.java:659)
	at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:531)
	at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
	at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:329)
	at java.util.TimerThread.mainLoop(Timer.java:555)
	at java.util.TimerThread.run(Timer.java:505)
Caused by: 
org.apache.cxf.service.factory.ServiceConstructionException
	at
org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:209)
	at
org.apache.camel.component.cxf.jaxrs.CxfRsConsumer.<init>(CxfRsConsumer.java:38)
	at
org.apache.camel.component.cxf.jaxrs.CxfRsEndpoint.createConsumer(CxfRsEndpoint.java:140)
	at
org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenConsumerRoute.java:65)
	at
org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java:80)
	at org.apache.camel.impl.RouteService.warmUp(RouteService.java:134)
	at
org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:2109)
	at
org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:2039)
	at
org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1827)
	at
org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1699)
	at
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1544)
	at
org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:179)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
	at
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1512)
	at
org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:228)
	at
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:118)
	at
org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:301)
	at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:96)
	at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
	at
org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:948)
	at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
	at
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
	at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
	at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
	at
org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:799)
	at
org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:446)
	at
org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:791)
	at
org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:296)
	at
org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1347)
	at
org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:743)
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
	at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
	at
org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:117)
	at
org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:281)
	at
org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:213)
	at
org.eclipse.jetty.util.component.ContainerLifeCycle.updateBeans(ContainerLifeCycle.java:763)
	at
org.eclipse.jetty.server.handler.HandlerCollection.setHandlers(HandlerCollection.java:89)
	at
org.eclipse.jetty.server.handler.ContextHandlerCollection.setHandlers(ContextHandlerCollection.java:144)
	at
org.eclipse.jetty.server.handler.HandlerCollection.addHandler(HandlerCollection.java:155)
	at
org.eclipse.jetty.deploy.bindings.StandardDeployer.processBinding(StandardDeployer.java:41)
	at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
	at
org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:498)
	at
org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
	at
org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileChanged(ScanningAppProvider.java:198)
	at
org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileChanged(ScanningAppProvider.java:70)
	at org.eclipse.jetty.util.Scanner.reportChange(Scanner.java:659)
	at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:531)
	at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
	at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:329)
	at java.util.TimerThread.mainLoop(Timer.java:555)
	at java.util.TimerThread.run(Timer.java:505)
Caused by: 
java.lang.NullPointerException
	at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:333)
	at
java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:1175)
	at
org.apache.cxf.transport.http.DestinationRegistryImpl.removeDestination(DestinationRegistryImpl.java:62)
	at
org.apache.cxf.transport.http.AbstractHTTPDestination.shutdown(AbstractHTTPDestination.java:886)
	at org.apache.cxf.endpoint.ServerImpl.destroy(ServerImpl.java:183)
	at
org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:198)
	at
org.apache.camel.component.cxf.jaxrs.CxfRsConsumer.<init>(CxfRsConsumer.java:38)
	at
org.apache.camel.component.cxf.jaxrs.CxfRsEndpoint.createConsumer(CxfRsEndpoint.java:140)
	at
org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenConsumerRoute.java:65)
	at
org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java:80)
	at org.apache.camel.impl.RouteService.warmUp(RouteService.java:134)
	at
org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:2109)
	at
org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:2039)
	at
org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1827)
	at
org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1699)
	at
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1544)
	at
org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:179)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
	at
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1512)
	at
org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:228)
	at
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:118)
	at
org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:301)
	at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:96)
	at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
	at
org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:948)
	at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
	at
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
	at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
	at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
	at
org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:799)
	at
org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:446)
	at
org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:791)
	at
org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:296)
	at
org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1347)
	at
org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:743)
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
	at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
	at
org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:117)
	at
org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:281)
	at
org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:213)
	at
org.eclipse.jetty.util.component.ContainerLifeCycle.updateBeans(ContainerLifeCycle.java:763)
	at
org.eclipse.jetty.server.handler.HandlerCollection.setHandlers(HandlerCollection.java:89)
	at
org.eclipse.jetty.server.handler.ContextHandlerCollection.setHandlers(ContextHandlerCollection.java:144)
	at
org.eclipse.jetty.server.handler.HandlerCollection.addHandler(HandlerCollection.java:155)
	at
org.eclipse.jetty.deploy.bindings.StandardDeployer.processBinding(StandardDeployer.java:41)
	at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
	at
org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:498)
	at
org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
	at
org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileChanged(ScanningAppProvider.java:198)
	at
org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileChanged(ScanningAppProvider.java:70)
	at org.eclipse.jetty.util.Scanner.reportChange(Scanner.java:659)
	at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:531)
	at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
	at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:329)
	at java.util.TimerThread.mainLoop(Timer.java:555)
	at java.util.TimerThread.run(Timer.java:505)
2014-03-28 15:55:02.967:INFO:oejwc.WebSocketClient:Scanner-0: Stopped
org.eclipse.jetty.websocket.client.WebSocketClient@1384634e
2014-03-28 15:55:02.979:INFO:edm:Scanner-0: Closing Spring root
WebApplicationContext
278372 [Scanner-0] INFO 
org.springframework.web.context.support.XmlWebApplicationContext  - Closing
Root WebApplicationContext: startup date [Fri Mar 28 15:50:24 IST 2014];
root of context hierarchy
278373 [Scanner-0] WARN 
org.springframework.web.context.support.XmlWebApplicationContext  -
Exception thrown from ApplicationListener handling ContextClosedEvent
java.lang.NullPointerException
	at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:333)
	at
java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:1175)
	at
org.apache.cxf.transport.http.DestinationRegistryImpl.removeDestination(DestinationRegistryImpl.java:62)
	at
org.apache.cxf.transport.http.AbstractHTTPDestination.deactivate(AbstractHTTPDestination.java:877)
	at
org.apache.cxf.transport.AbstractObservable.setMessageObserver(AbstractObservable.java:58)
	at org.apache.cxf.endpoint.ServerImpl.stop(ServerImpl.java:176)
	at org.apache.cxf.endpoint.ServerImpl.destroy(ServerImpl.java:181)
	at
org.apache.cxf.bus.managers.ServerRegistryImpl.preShutdown(ServerRegistryImpl.java:90)
	at
org.apache.cxf.bus.managers.CXFBusLifeCycleManager.preShutdown(CXFBusLifeCycleManager.java:95)
	at
org.apache.cxf.bus.managers.CXFBusLifeCycleManager.postShutdown(CXFBusLifeCycleManager.java:102)
	at
org.apache.cxf.bus.spring.SpringBus.onApplicationEvent(SpringBus.java:113)
	at
org.apache.cxf.bus.spring.SpringBus$1.onApplicationEvent(SpringBus.java:64)
	at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:96)
	at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
	at
org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1049)
	at
org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
	at
org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:559)
	at
org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)
	at
org.eclipse.jetty.server.handler.ContextHandler.callContextDestroyed(ContextHandler.java:806)
	at
org.eclipse.jetty.servlet.ServletContextHandler.callContextDestroyed(ServletContextHandler.java:459)
	at
org.eclipse.jetty.server.handler.ContextHandler.doStop(ContextHandler.java:840)
	at
org.eclipse.jetty.servlet.ServletContextHandler.doStop(ServletContextHandler.java:217)
	at org.eclipse.jetty.webapp.WebAppContext.doStop(WebAppContext.java:516)
	at
org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:90)
	at
org.eclipse.jetty.deploy.bindings.StandardStopper.processBinding(StandardStopper.java:44)
	at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
	at
org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:498)
	at
org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:458)
	at
org.eclipse.jetty.deploy.DeploymentManager.removeApp(DeploymentManager.java:409)
	at
org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileRemoved(ScanningAppProvider.java:209)
	at
org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileRemoved(ScanningAppProvider.java:76)
	at org.eclipse.jetty.util.Scanner.reportRemoval(Scanner.java:632)
	at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:534)
	at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
	at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:329)
	at java.util.TimerThread.mainLoop(Timer.java:555)
	at java.util.TimerThread.run(Timer.java:505)


Any idea?



--
View this message in context: http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749495.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Issues with cxfrs using json

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

I was experimenting with using CXF JSONProvider with cxfrs routes few 
weeks ago, it was working OK, posting and getting JSON back...
I'm not sure why you need to add a jaxrs bundle dep to get JSONProvider 
active, do you work with the version of Camel ? JSONProvider is in CXF 
cxf-rt-extensions-providers since CXF 2.6.0

May be you should try the later Camel version ?

Cheers, Sergey
On 28/03/14 09:13, bijoy wrote:
> The log with showAll=true provides following...
>
> Exchange[Id: ID-PG85238-43050-1395997134260-0-2, ExchangePattern: InOut,
> Properties: {CamelCreatedTimestamp=Fri Mar 28 14:30:18 IST 2014,
> CamelMessageHistory=[DefaultMessageHistory[routeId=httpRequest, node=to1]],
> CamelToEndpoint=log://?showAll=true}, Headers:
> {breadcrumbId=ID-PG85238-43050-1395997134260-0-1,
> CamelAcceptContentType=*/*,
> CamelCxfMessage=org.apache.cxf.message.XMLMessage@84f9cd67,
> CamelCxfRsOperationResourceInfoStack=[org.apache.cxf.jaxrs.model.MethodInvocationInfo@5ce5ef67],
> CamelCxfRsResponseClass=class javax.ws.rs.core.Response,
> CamelCxfRsResponseGenericType=class javax.ws.rs.core.Response,
> CamelHttpCharacterEncoding=ISO-8859-1, CamelHttpMethod=POST,
> CamelHttpPath=/orders/4001/delta, CamelHttpUri=/orders/4001/delta,
> connection=keep-alive, Content-Length=100, content-type=application/json,
> Host=localhost:42107, operationName=createDelta, orderId=4001}, BodyType:
> org.apache.cxf.message.MessageContentsList, Body: [], Out: null: ]
>
> Also the log before the exception was throw...
>
> 2014-03-28T14:30:18.000399+0530 [qtp1885697564-37] ERROR
> org.apache.camel.util.CamelLogger:215 log Failed delivery for (MessageId:
> ID-PG85238-43050-1395997134260-0-1 on ExchangeId:
> ID-PG85238-43050-1395997134260-0-2). Exhausted after delivery attempt: 1
> caught: java.lang.NullPointerException
>
> Message History
> ---------------------------------------------------------------------------------------------------------------------------------------
> RouteId              ProcessorId          Processor
> Elapsed (ms)
> [httpRequest       ] [httpRequest       ]
> [cxfrs://bean://restServer?bindingStyle=SimpleConsumer
> ] [        62]
> [httpRequest       ] [to1               ] [log:?showAll=true
> ] [         6]
> [httpRequest       ] [process3          ] [ref:processRequest
> ] [         6]
>
> Exchange
> ---------------------------------------------------------------------------------------------------------------------------------------
> Exchange[
> 	Id                  ID-PG85238-43050-1395997134260-0-2
> 	ExchangePattern     InOut
> 	Headers             {breadcrumbId=ID-PG85238-43050-1395997134260-0-1,
> CamelAcceptContentType=*/*,
> CamelCxfMessage=org.apache.cxf.message.XMLMessage@84f9cd67,
> CamelCxfRsOperationResourceInfoStack=[org.apache.cxf.jaxrs.model.MethodInvocationInfo@5ce5ef67],
> CamelCxfRsResponseClass=class javax.ws.rs.core.Response,
> CamelCxfRsResponseGenericType=class javax.ws.rs.core.Response,
> CamelHttpCharacterEncoding=ISO-8859-1, CamelHttpMethod=POST,
> CamelHttpPath=/orders/4001/delta, CamelHttpUri=/orders/4001/delta,
> CamelRedelivered=false, CamelRedeliveryCounter=0, connection=keep-alive,
> Content-Length=100, content-type=application/json, Host=localhost:42107,
> operationName=createDelta, orderId=4001}
> 	BodyType            org.apache.cxf.message.MessageContentsList
> 	Body                []
> ]
>
> Stacktrace
> ---------------------------------------------------------------------------------------------------------------------------------------
> java.lang.NullPointerException: null
>
> *RestServices.java*
> @Path("/orders/{orderId}")
> public class RestServices {
>      @POST
>      @Consumes("application/json")
>      @Produces("application/json")
>      @Path("/delta")
>      public Response createDelta() {
>             return null;
>      }
> }
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749486.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Issues with cxfrs using json

Posted by bijoy <bi...@gmail.com>.
The log with showAll=true provides following...

Exchange[Id: ID-PG85238-43050-1395997134260-0-2, ExchangePattern: InOut,
Properties: {CamelCreatedTimestamp=Fri Mar 28 14:30:18 IST 2014,
CamelMessageHistory=[DefaultMessageHistory[routeId=httpRequest, node=to1]],
CamelToEndpoint=log://?showAll=true}, Headers:
{breadcrumbId=ID-PG85238-43050-1395997134260-0-1,
CamelAcceptContentType=*/*,
CamelCxfMessage=org.apache.cxf.message.XMLMessage@84f9cd67,
CamelCxfRsOperationResourceInfoStack=[org.apache.cxf.jaxrs.model.MethodInvocationInfo@5ce5ef67],
CamelCxfRsResponseClass=class javax.ws.rs.core.Response,
CamelCxfRsResponseGenericType=class javax.ws.rs.core.Response,
CamelHttpCharacterEncoding=ISO-8859-1, CamelHttpMethod=POST,
CamelHttpPath=/orders/4001/delta, CamelHttpUri=/orders/4001/delta,
connection=keep-alive, Content-Length=100, content-type=application/json,
Host=localhost:42107, operationName=createDelta, orderId=4001}, BodyType:
org.apache.cxf.message.MessageContentsList, Body: [], Out: null: ]

Also the log before the exception was throw...

2014-03-28T14:30:18.000399+0530 [qtp1885697564-37] ERROR
org.apache.camel.util.CamelLogger:215 log Failed delivery for (MessageId:
ID-PG85238-43050-1395997134260-0-1 on ExchangeId:
ID-PG85238-43050-1395997134260-0-2). Exhausted after delivery attempt: 1
caught: java.lang.NullPointerException

Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                                       
Elapsed (ms)
[httpRequest       ] [httpRequest       ]
[cxfrs://bean://restServer?bindingStyle=SimpleConsumer                        
] [        62]
[httpRequest       ] [to1               ] [log:?showAll=true                                                            
] [         6]
[httpRequest       ] [process3          ] [ref:processRequest                                                          
] [         6]

Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange[
	Id                  ID-PG85238-43050-1395997134260-0-2
	ExchangePattern     InOut
	Headers             {breadcrumbId=ID-PG85238-43050-1395997134260-0-1,
CamelAcceptContentType=*/*,
CamelCxfMessage=org.apache.cxf.message.XMLMessage@84f9cd67,
CamelCxfRsOperationResourceInfoStack=[org.apache.cxf.jaxrs.model.MethodInvocationInfo@5ce5ef67],
CamelCxfRsResponseClass=class javax.ws.rs.core.Response,
CamelCxfRsResponseGenericType=class javax.ws.rs.core.Response,
CamelHttpCharacterEncoding=ISO-8859-1, CamelHttpMethod=POST,
CamelHttpPath=/orders/4001/delta, CamelHttpUri=/orders/4001/delta,
CamelRedelivered=false, CamelRedeliveryCounter=0, connection=keep-alive,
Content-Length=100, content-type=application/json, Host=localhost:42107,
operationName=createDelta, orderId=4001}
	BodyType            org.apache.cxf.message.MessageContentsList
	Body                []
]

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
java.lang.NullPointerException: null

*RestServices.java*
@Path("/orders/{orderId}")
public class RestServices {
    @POST
    @Consumes("application/json")
    @Produces("application/json")
    @Path("/delta")
    public Response createDelta() {
           return null;
    }
}



--
View this message in context: http://camel.465427.n5.nabble.com/Issues-with-cxfrs-using-json-tp5749474p5749486.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Issues with cxfrs using json

Posted by Raul Kripalani <ra...@evosent.com>.
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 <bi...@gmail.com> 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.