You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by hom <tl...@sharklasers.com> on 2012/07/23 17:10:10 UTC

CXFRS does not process JSON

Hi,

I've created a cxfrs route as described in
http://camel.apache.org/cxfrs.html (How to consume the REST request in
Camel). I am using SOAPUI to test the endpoint. The resource class is:

/@Path("/")
@Consumes({"application/xml","application/json"})
@Produces({"application/xml","application/json"})
public class Resource {
 
	@POST
	@Path("/doit/")
	@Consumes({"application/xml","application/json"})
	@Produces({"application/xml","application/json"})
    public DoItResponse doit(DoItRequest request){return null;};
}/

For XML everything works fine, but when I send a json request I always get:

<data contentType="text/plain" contentLength="555"><![CDATA[JAXBException
occurred : unexpected element (uri:"", local:"DoItRequest"). Expected
elements are
<{http://www.xyz.org/types}DoItRequest>,<{http://www.xyz.org/types}DoItResponse>,<{http://www.xyz.org/types}
ProviderError>. unexpected element (uri:"", local:"DoItRequest") ...

I set media type and access header to application/json, but it seems that
json is not recognized.
Any ideas?






--
View this message in context: http://camel.465427.n5.nabble.com/CXFRS-does-not-process-JSON-tp5716343.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXFRS does not process JSON

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

On 24/07/12 14:47, hom wrote:
> I managed to wire up the bus to the endpoint by adding bus="tb" to the bus
> element.
>
> But now I get a NullPointerException. It seems that the
> TransformInInterceptor has problems transformig the message. Here is the
> stack trace:
>
I apologize, I did not give you enough info.

Basically, Jettison-based provider is not capable of reading from the 
regular XMLStreamReaders that the transform feature creates; the 
provider creates its on Jettison mapped stream reader which attempts to 
parse the sequence, and such - and all the customization which we can do 
is done at the top of that JSON reader. Using the feature works with 
XML-based providers or even with Jettison on the outbound side, but to 
do this kind of conversion on the inbound side, one has to explicitly 
configure JSONProvider, as suggested here:

http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-CustomizingJAXBXMLandJSONinputandoutput

The provider then needs to be registered directly with the rs endpoint

Cheers, Sergey

> 2012-07-24 15:30:57,905 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain
> | .cxf.phase.PhaseInterceptorChain  674 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Chain org.apache.cxf.phase.PhaseInterceptorChain@e2e59e was created.
> Current flow:
>    receive [LoggingInInterceptor, PolicyInInterceptor]
>    pre-stream [CertConstraintsInterceptor]
>    post-stream [TransformInInterceptor]
>    unmarshal [JAXRSInInterceptor]
>    pre-logical [OneWayProcessorInterceptor]
>    invoke [ServiceInvokerInterceptor]
>    post-invoke [OutgoingChainInterceptor]
>
> 2012-07-24 15:30:57,905 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain
> | .cxf.phase.PhaseInterceptorChain  259 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Invoking handleMessage on interceptor
> org.apache.cxf.interceptor.LoggingInInterceptor@10d144e
> 2012-07-24 15:30:57,935 | INFO  | er/v1/json/doit/ | LoggingInInterceptor
> | eptor.AbstractLoggingInterceptor  233 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Inbound Message
> ----------------------------
> ID: 1
> Address: http://localhost:8181/cxf/xyz/json/doit/
> Encoding: ISO-8859-1
> Http-Method: POST
> Content-Type: application/json
> Headers: {Accept=[application/json], accept-encoding=[gzip,deflate],
> Content-Length=[33], content-type=[application/json], Host=[localhost:8181],
> User-Agent=[Jakarta Commons-HttpClient/3.1]}
> Payload: {"DoItRequest":{"country":"DE"}}
>
> --------------------------------------
> 2012-07-24 15:30:57,935 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain
> | .cxf.phase.PhaseInterceptorChain  259 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Invoking handleMessage on interceptor
> org.apache.cxf.ws.policy.PolicyInInterceptor@688c5d
> 2012-07-24 15:30:57,935 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain
> | .cxf.phase.PhaseInterceptorChain  259 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Invoking handleMessage on interceptor
> org.apache.cxf.transport.https.CertConstraintsInterceptor@1abf87e
> 2012-07-24 15:30:57,935 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain
> | .cxf.phase.PhaseInterceptorChain  259 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Invoking handleMessage on interceptor
> org.apache.cxf.interceptor.transform.TransformInInterceptor@1d76e81
> 2012-07-24 15:30:59,157 | DEBUG | heckpoint Worker | MessageDatabase
> | emq.store.kahadb.MessageDatabase 1349 | 196 -
> org.apache.activemq.activemq-core - 5.6.0 | Checkpoint started.
> 2012-07-24 15:30:59,257 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain
> | .cxf.phase.PhaseInterceptorChain  259 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Invoking handleMessage on interceptor
> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor@93660b
> 2012-07-24 15:30:59,317 | DEBUG | er/v1/json/doit/ | JAXRSUtils
> | pache.cxf.jaxrs.utils.JAXRSUtils  234 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Trying to select a resource class, request path : /doit/
> 2012-07-24 15:30:59,347 | DEBUG | er/v1/json/doit/ | JAXRSUtils
> | pache.cxf.jaxrs.utils.JAXRSUtils  296 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Trying to select a resource operation on the resource class
> org.xyz.routes.json.Resource
> 2012-07-24 15:30:59,347 | DEBUG | er/v1/json/doit/ | JAXRSUtils
> | pache.cxf.jaxrs.utils.JAXRSUtils  354 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Resource operation doit may get selected
> 2012-07-24 15:30:59,347 | DEBUG | er/v1/json/doit/ | JAXRSUtils
> | pache.cxf.jaxrs.utils.JAXRSUtils  378 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Resource operation doit on the resource class
> org.xyz.routes.json.Resource has been selected
> 2012-07-24 15:30:59,347 | DEBUG | er/v1/json/doit/ | JAXRSInInterceptor
> | s.interceptor.JAXRSInInterceptor  227 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Request path is: /doit/
> 2012-07-24 15:30:59,347 | DEBUG | er/v1/json/doit/ | JAXRSInInterceptor
> | s.interceptor.JAXRSInInterceptor  228 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Request HTTP method is: POST
> 2012-07-24 15:30:59,347 | DEBUG | er/v1/json/doit/ | JAXRSInInterceptor
> | s.interceptor.JAXRSInInterceptor  229 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Request contentType is: application/json
> 2012-07-24 15:30:59,357 | DEBUG | er/v1/json/doit/ | JAXRSInInterceptor
> | s.interceptor.JAXRSInInterceptor  230 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Accept contentType is: application/json
> 2012-07-24 15:30:59,357 | DEBUG | er/v1/json/doit/ | JAXRSInInterceptor
> | s.interceptor.JAXRSInInterceptor  232 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Found operation: doit
> 2012-07-24 15:30:59,377 | DEBUG | er/v1/json/doit/ | bind
> | javax.xml.bind.ContextFinder      258 |  -  -  | Searching jaxb.properties
> 2012-07-24 15:30:59,377 | DEBUG | er/v1/json/doit/ | bind
> | javax.xml.bind.ContextFinder      276 |  -  -  | Searching the system
> property
> 2012-07-24 15:30:59,377 | DEBUG | er/v1/json/doit/ | bind
> | javax.xml.bind.ContextFinder      284 |  -  -  | Searching
> META-INF/services
> 2012-07-24 15:30:59,377 | DEBUG | er/v1/json/doit/ | bind
> | javax.xml.bind.ContextFinder      299 |  -  -  | Unable to
> load:META-INF/services/javax.xml.bind.JAXBContext
> 2012-07-24 15:30:59,377 | DEBUG | er/v1/json/doit/ | bind
> | javax.xml.bind.ContextFinder      309 |  -  -  | Trying to create the
> platform default provider
> 2012-07-24 15:30:59,377 | DEBUG | heckpoint Worker | MessageDatabase
> | emq.store.kahadb.MessageDatabase 1484 | 196 -
> org.apache.activemq.activemq-core - 5.6.0 | Checkpoint done.
> 2012-07-24 15:30:59,377 | DEBUG | er/v1/json/doit/ | ContextFactory
> | m.sun.xml.bind.v2.ContextFactory  102 |  -  -  | Property
> com.sun.xml.bind.XmlAccessorFactoryis not active.  Using JAXB's
> implementation
> 2012-07-24 15:30:59,618 | DEBUG | er/v1/json/doit/ |
> WebApplicationExceptionMapper    | pl.WebApplicationExceptionMapper   62 |
> 119 - org.apache.cxf.cxf-api - 2.6.1 | WebApplicationException has been
> caught, status: 400, message: exception cause class:
> java.lang.NullPointerException
> javax.ws.rs.WebApplicationException: java.lang.NullPointerException
> 	at
> org.apache.cxf.jaxrs.provider.json.JSONProvider.readFrom(JSONProvider.java:246)[130:org.apache.cxf.cxf-rt-rs-extension-providers:2.6.1]
> 	at
> org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1038)[132:org.apache.cxf.cxf-rt-frontend-jaxrs:2.6.1]
> 	at
> org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:614)[132:org.apache.cxf.cxf-rt-frontend-jaxrs:2.6.1]
> 	at
> org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:578)[132:org.apache.cxf.cxf-rt-frontend-jaxrs:2.6.1]
> 	at
> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:238)[132:org.apache.cxf.cxf-rt-frontend-jaxrs:2.6.1]
> 	at
> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:89)[132:org.apache.cxf.cxf-rt-frontend-jaxrs:2.6.1]
> 	at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)[119:org.apache.cxf.cxf-api:2.6.1]
> 	at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122)[119:org.apache.cxf.cxf-api:2.6.1]
> 	at
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:211)[126:org.apache.cxf.cxf-rt-transports-http:2.6.1]
> 	at
> org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213)[126:org.apache.cxf.cxf-rt-transports-http:2.6.1]
> 	at
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154)[126:org.apache.cxf.cxf-rt-transports-http:2.6.1]
> 	at
> org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:129)[126:org.apache.cxf.cxf-rt-transports-http:2.6.1]
> 	at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:187)[126:org.apache.cxf.cxf-rt-transports-http:2.6.1]
> 	at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:110)[126:org.apache.cxf.cxf-rt-transports-http:2.6.1]
> 	at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:713)[61:org.apache.geronimo.specs.geronimo-servlet_2.5_spec:1.1.2]
> 	at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:166)[126:org.apache.cxf.cxf-rt-transports-http:2.6.1]
> 	at
> org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:547)[72:org.eclipse.jetty.servlet:7.5.4.v20111024]
> 	at
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:480)[72:org.eclipse.jetty.servlet:7.5.4.v20111024]
> 	at
> org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:70)[82:org.ops4j.pax.web.pax-web-jetty:1.0.9]
> 	at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)[70:org.eclipse.jetty.server:7.5.4.v20111024]
> 	at
> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520)[71:org.eclipse.jetty.security:7.5.4.v20111024]
> 	at
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)[70:org.eclipse.jetty.server:7.5.4.v20111024]
> 	at
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:941)[70:org.eclipse.jetty.server:7.5.4.v20111024]
> 	at
> org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:117)[82:org.ops4j.pax.web.pax-web-jetty:1.0.9]
> 	at
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:409)[72:org.eclipse.jetty.servlet:7.5.4.v20111024]
> 	at
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)[70:org.eclipse.jetty.server:7.5.4.v20111024]
> 	at
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:875)[70:org.eclipse.jetty.server:7.5.4.v20111024]
> 	at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)[70:org.eclipse.jetty.server:7.5.4.v20111024]
> 	at
> org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:72)[82:org.ops4j.pax.web.pax-web-jetty:1.0.9]
> 	at
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)[70:org.eclipse.jetty.server:7.5.4.v20111024]
> 	at
> org.eclipse.jetty.server.Server.handle(Server.java:345)[70:org.eclipse.jetty.server:7.5.4.v20111024]
> 	at
> org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:441)[70:org.eclipse.jetty.server:7.5.4.v20111024]
> 	at
> org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:936)[70:org.eclipse.jetty.server:7.5.4.v20111024]
> 	at
> org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:801)[66:org.eclipse.jetty.http:7.5.4.v20111024]
> 	at
> org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:224)[66:org.eclipse.jetty.http:7.5.4.v20111024]
> 	at
> org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)[70:org.eclipse.jetty.server:7.5.4.v20111024]
> 	at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)[65:org.eclipse.jetty.io:7.5.4.v20111024]
> 	at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)[65:org.eclipse.jetty.io:7.5.4.v20111024]
> 	at
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)[64:org.eclipse.jetty.util:7.5.4.v20111024]
> 	at
> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)[64:org.eclipse.jetty.util:7.5.4.v20111024]
> 	at java.lang.Thread.run(Thread.java:662)[:1.6.0_24]
> Caused by: java.lang.NullPointerException
> 	at
> org.codehaus.jettison.AbstractXMLInputFactory.readAll(AbstractXMLInputFactory.java:122)[129:org.codehaus.jettison.jettison:1.3.1]
> 	at
> org.codehaus.jettison.AbstractXMLInputFactory.createXMLStreamReader(AbstractXMLInputFactory.java:105)[129:org.codehaus.jettison.jettison:1.3.1]
> 	at
> org.codehaus.jettison.AbstractXMLInputFactory.createXMLStreamReader(AbstractXMLInputFactory.java:93)[129:org.codehaus.jettison.jettison:1.3.1]
> 	at
> org.apache.cxf.jaxrs.provider.json.utils.JSONUtils.createStreamReader(JSONUtils.java:159)[130:org.apache.cxf.cxf-rt-rs-extension-providers:2.6.1]
> 	at
> org.apache.cxf.jaxrs.provider.json.JSONProvider.createReader(JSONProvider.java:264)[130:org.apache.cxf.cxf-rt-rs-extension-providers:2.6.1]
> 	at
> org.apache.cxf.jaxrs.provider.json.JSONProvider.createReader(JSONProvider.java:254)[130:org.apache.cxf.cxf-rt-rs-extension-providers:2.6.1]
> 	at
> org.apache.cxf.jaxrs.provider.json.JSONProvider.readFrom(JSONProvider.java:216)[130:org.apache.cxf.cxf-rt-rs-extension-providers:2.6.1]
> 	... 40 more
> 2012-07-24 15:30:59,658 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain
> | .cxf.phase.PhaseInterceptorChain  259 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Invoking handleMessage on interceptor
> org.apache.cxf.interceptor.OneWayProcessorInterceptor@1768eb6
> 2012-07-24 15:30:59,658 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain
> | .cxf.phase.PhaseInterceptorChain  259 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Invoking handleMessage on interceptor
> org.apache.cxf.interceptor.ServiceInvokerInterceptor@97d818
> 2012-07-24 15:30:59,658 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain
> | .cxf.phase.PhaseInterceptorChain  259 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Invoking handleMessage on interceptor
> org.apache.cxf.interceptor.OutgoingChainInterceptor@ec4446
> 2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ |
> OutgoingChainInterceptor         | rceptor.OutgoingChainInterceptor  176 |
> 119 - org.apache.cxf.cxf-api - 2.6.1 | Interceptors contributed by bus:
> [org.apache.cxf.interceptor.LoggingOutInterceptor@1ba9eea,
> org.apache.cxf.ws.policy.PolicyOutInterceptor@1173763,
> org.apache.cxf.interceptor.transform.TransformOutInterceptor@1354d59]
> 2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ |
> OutgoingChainInterceptor         | rceptor.OutgoingChainInterceptor  180 |
> 119 - org.apache.cxf.cxf-api - 2.6.1 | Interceptors contributed by service:
> []
> 2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ |
> OutgoingChainInterceptor         | rceptor.OutgoingChainInterceptor  184 |
> 119 - org.apache.cxf.cxf-api - 2.6.1 | Interceptors contributed by endpoint:
> [org.apache.cxf.interceptor.MessageSenderInterceptor@6913ce]
> 2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ |
> OutgoingChainInterceptor         | rceptor.OutgoingChainInterceptor  190 |
> 119 - org.apache.cxf.cxf-api - 2.6.1 | Interceptors contributed by binding:
> [org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor@9366ba]
> 2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain
> | .cxf.phase.PhaseInterceptorChain  205 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Adding interceptor
> org.apache.cxf.interceptor.LoggingOutInterceptor@1ba9eea to phase pre-stream
> 2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain
> | .cxf.phase.PhaseInterceptorChain  205 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Adding interceptor
> org.apache.cxf.ws.policy.PolicyOutInterceptor@1173763 to phase setup
> 2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain
> | .cxf.phase.PhaseInterceptorChain  205 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Adding interceptor
> org.apache.cxf.interceptor.transform.TransformOutInterceptor@1354d59 to
> phase pre-stream
> 2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain
> | .cxf.phase.PhaseInterceptorChain  205 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Adding interceptor
> org.apache.cxf.interceptor.MessageSenderInterceptor@6913ce to phase
> prepare-send
> 2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain
> | .cxf.phase.PhaseInterceptorChain  205 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Adding interceptor
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor@9366ba to phase marshal
> 2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain
> | .cxf.phase.PhaseInterceptorChain  674 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Chain org.apache.cxf.phase.PhaseInterceptorChain@13d6bcb was
> created. Current flow:
>    setup [PolicyOutInterceptor]
>    prepare-send [MessageSenderInterceptor]
>    pre-stream [LoggingOutInterceptor, TransformOutInterceptor]
>    marshal [JAXRSOutInterceptor]
>
> 2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain
> | .cxf.phase.PhaseInterceptorChain  259 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | Invoking handleMessage on interceptor
> org.apache.cxf.ws.policy.PolicyOutInterceptor@1173763
> 2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ | PolicyOutInterceptor
> | f.ws.policy.PolicyOutInterceptor   63 | 119 - org.apache.cxf.cxf-api -
> 2.6.1 | No binding operation info.
> 2012-07-
>
> Do you have an idea what could be wrong here?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CXFRS-does-not-process-JSON-tp5716343p5716403.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: CXFRS does not process JSON

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 25/07/12 16:37, hom wrote:
> The journey comes to an end. I managed to create the json endpoint.
> It does not use Camel but plain CXF.
> This is the final configuration (quite simple actually ;-) ):
>
>      <jaxrs:server id="providerPOXJSON" address="/xyz/json">
>          <jaxrs:serviceBeans>
>              <ref component-id="providerAdapter"/>
>          </jaxrs:serviceBeans>
>          <jaxrs:providers>
>            <ref component-id="jsonProvider" />
>          </jaxrs:providers>
>      </jaxrs:server>
>
>      <bean id="jsonProvider"
> class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
>        <property name="inTransformElements">
>          <map>
>            <entry key="*" value="{http://xyz/types}*"/>
>          </map>
>        </property>
>      </bean>
>
>      <bean id="providerAdapter" class="org.xyz.ProviderAdapter"/>
>
Thanks for the patience and making it work :-).
I guess we can also use a camel transport URI within 
jaxrs:server/@address; however, I'm interested to see how it can be set 
up with the Camel RS Server component, I'll play a bit later on.

Cheers, Sergey

>
> Thank you very much for your help.
>
> Cheers
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CXFRS-does-not-process-JSON-tp5716343p5716468.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Re: CXFRS does not process JSON

Posted by hom <tl...@sharklasers.com>.
The journey comes to an end. I managed to create the json endpoint.
It does not use Camel but plain CXF.
This is the final configuration (quite simple actually ;-) ):

    <jaxrs:server id="providerPOXJSON" address="/xyz/json">
        <jaxrs:serviceBeans>
            <ref component-id="providerAdapter"/>
        </jaxrs:serviceBeans>
        <jaxrs:providers> 
          <ref component-id="jsonProvider" /> 
        </jaxrs:providers> 
    </jaxrs:server>

    <bean id="jsonProvider"
class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
      <property name="inTransformElements">
        <map>
          <entry key="*" value="{http://xyz/types}*"/>
        </map>
      </property>
    </bean>

    <bean id="providerAdapter" class="org.xyz.ProviderAdapter"/>


Thank you very much for your help.

Cheers



--
View this message in context: http://camel.465427.n5.nabble.com/CXFRS-does-not-process-JSON-tp5716343p5716468.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXFRS does not process JSON

Posted by hom <tl...@sharklasers.com>.
The provider then needs to be registered directly with the rs endpoint

The classloading error is gone now, but I have no idea how register the
jsonprovider with the rs endpoint.
How can this be done?
 



--
View this message in context: http://camel.465427.n5.nabble.com/CXFRS-does-not-process-JSON-tp5716343p5716463.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXFRS does not process JSON

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 25/07/12 11:12, hom wrote:
> In order to configure the JSONProvider, I switched to the server approach:
>
>       <jaxrs:server id="providerPOXJSON" address="/xyz/json">
>          <jaxrs:serviceBeans>
>              <ref component-id="providerAdapter"/>
>          </jaxrs:serviceBeans>
>          <jaxrs:providers>
>            <ref component-id="jsonProvider" />
>          </jaxrs:providers>
>      </jaxrs:server>
>
>     <bean id="providerAdapter" class="org.xyz.json.ProviderAdapter"/>
>
>      <bean id="jsonProvider"
> class="org.apache.cxf.jaxrs.provider.JSONProvider">

The complete class name is 
"org.apache.cxf.jaxrs.provider.json.JSONProvider" in CXF 2.6.1, I can 
see the docs wrongly referring to the old package in a couple of places, 
will get that fixed now.
You'll also need to add
<dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-rt-rs-extension-providers</artifactId>
             <version>2.6.1</version>
         </dependency>
<dependency>
            <groupId>org.codehaus.jettison</groupId>
            <artifactId>jettison</artifactId>
            <version>1.3.1</version>
         </dependency>


Note in Camel you can do
<jaxrs:server id="providerPOXJSON" address="camel://direct:xyzJSON">

I've also seen a cxfrs rsServer component having a <providers> element, 
but I haven't tried.

HTH, Sergey

> 	<property name="namespaceMap">
> 	<map>
> 	<entry key="DoItRequest" value="{http://xyz/types}DoItRequest"/>
> 	</map>
> 	</property>
>      </bean>
>
> When I deploy this I get the following error:
>
> Caused by: java.lang.ClassNotFoundException:
> org.apache.cxf.jaxrs.provider.JSONProvider not found by
> org.apache.cxf.cxf-rt-frontend-jaxrs [132]
> 	at
> org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)[org.apache.felix.framework-3.0.9.jar:]
> 	at
> org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)[org.apache.felix.framework-3.0.9.jar:]
> 	at
> org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)[org.apache.felix.framework-3.0.9.jar:]
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)[:1.6.0_24]
> 	at
> org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:645)[org.apache.felix.framework-3.0.9.jar:]
> 	at
> org.apache.felix.framework.resolver.WireImpl.getClass(WireImpl.java:99)[org.apache.felix.framework-3.0.9.jar:]
> 	at
> org.apache.felix.framework.ModuleImpl.searchImports(ModuleImpl.java:1390)[org.apache.felix.framework-3.0.9.jar:]
> 	at
> org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:722)[org.apache.felix.framework-3.0.9.jar:]
> 	at
> org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)[org.apache.felix.framework-3.0.9.jar:]
> 	at
> org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)[org.apache.felix.framework-3.0.9.jar:]
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)[:1.6.0_24]
> 	at
> org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:645)[org.apache.felix.framework-3.0.9.jar:]
> 	at
> org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1619)[org.apache.felix.framework-3.0.9.jar:]
> 	at
> org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:900)[org.apache.felix.framework-3.0.9.jar:]
> 	at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.loadClass(BlueprintContainerImpl.java:384)[10:org.apache.aries.blueprint:0.3.1]
> 	at
> org.apache.aries.blueprint.container.BlueprintRepository.loadClass(BlueprintRepository.java:381)[10:org.apache.aries.blueprint:0.3.1]
> 	at
> org.apache.aries.blueprint.container.GenericType.parse(GenericType.java:113)[10:org.apache.aries.blueprint:0.3.1]
> 	at
> org.apache.aries.blueprint.di.AbstractRecipe.loadType(AbstractRecipe.java:110)[10:org.apache.aries.blueprint:0.3.1]
>
>
> It seems that cxf-rt-frontend-jaxrs does not have access to the JSONProvider
> class. The bundle does not import the required package.
>
> Do you have an idea how to fix that?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CXFRS-does-not-process-JSON-tp5716343p5716449.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



Re: CXFRS does not process JSON

Posted by hom <tl...@sharklasers.com>.
In order to configure the JSONProvider, I switched to the server approach:

     <jaxrs:server id="providerPOXJSON" address="/xyz/json">
        <jaxrs:serviceBeans>
            <ref component-id="providerAdapter"/>
        </jaxrs:serviceBeans>
        <jaxrs:providers> 
          <ref component-id="jsonProvider" /> 
        </jaxrs:providers> 
    </jaxrs:server>

   <bean id="providerAdapter" class="org.xyz.json.ProviderAdapter"/>

    <bean id="jsonProvider"
class="org.apache.cxf.jaxrs.provider.JSONProvider">
	    <property name="namespaceMap">
	        <map>
	          <entry key="DoItRequest" value="{http://xyz/types}DoItRequest"/>
	        </map>
	    </property>
    </bean>

When I deploy this I get the following error:

Caused by: java.lang.ClassNotFoundException:
org.apache.cxf.jaxrs.provider.JSONProvider not found by
org.apache.cxf.cxf-rt-frontend-jaxrs [132]
	at
org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)[org.apache.felix.framework-3.0.9.jar:]
	at
org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)[org.apache.felix.framework-3.0.9.jar:]
	at
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)[org.apache.felix.framework-3.0.9.jar:]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)[:1.6.0_24]
	at
org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:645)[org.apache.felix.framework-3.0.9.jar:]
	at
org.apache.felix.framework.resolver.WireImpl.getClass(WireImpl.java:99)[org.apache.felix.framework-3.0.9.jar:]
	at
org.apache.felix.framework.ModuleImpl.searchImports(ModuleImpl.java:1390)[org.apache.felix.framework-3.0.9.jar:]
	at
org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:722)[org.apache.felix.framework-3.0.9.jar:]
	at
org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)[org.apache.felix.framework-3.0.9.jar:]
	at
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)[org.apache.felix.framework-3.0.9.jar:]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)[:1.6.0_24]
	at
org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:645)[org.apache.felix.framework-3.0.9.jar:]
	at
org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1619)[org.apache.felix.framework-3.0.9.jar:]
	at
org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:900)[org.apache.felix.framework-3.0.9.jar:]
	at
org.apache.aries.blueprint.container.BlueprintContainerImpl.loadClass(BlueprintContainerImpl.java:384)[10:org.apache.aries.blueprint:0.3.1]
	at
org.apache.aries.blueprint.container.BlueprintRepository.loadClass(BlueprintRepository.java:381)[10:org.apache.aries.blueprint:0.3.1]
	at
org.apache.aries.blueprint.container.GenericType.parse(GenericType.java:113)[10:org.apache.aries.blueprint:0.3.1]
	at
org.apache.aries.blueprint.di.AbstractRecipe.loadType(AbstractRecipe.java:110)[10:org.apache.aries.blueprint:0.3.1]


It seems that cxf-rt-frontend-jaxrs does not have access to the JSONProvider
class. The bundle does not import the required package.

Do you have an idea how to fix that?



--
View this message in context: http://camel.465427.n5.nabble.com/CXFRS-does-not-process-JSON-tp5716343p5716449.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXFRS does not process JSON

Posted by hom <tl...@sharklasers.com>.
The provider then needs to be registered directly with the rs endpoint
How can this be done? Is it possible in blueprint or in the java camel
route?
Could you please provide an example?



--
View this message in context: http://camel.465427.n5.nabble.com/CXFRS-does-not-process-JSON-tp5716343p5716415.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXFRS does not process JSON

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 24/07/12 16:17, hom wrote:
> I investigated further and found that in JAXRSUtils.processParameter the
> statement
>
> InputStream is = message.getContent(InputStream.class);
>
> returns null.
>
> If I look into the contents of the XMlMessage I see:
>
> class org.apache.cxf.io.DelegatingInputStream
> org.apache.cxf.transport.http.AbstractHTTPDestination$1@1963e55
> interface javax.xml.stream.XMLStreamReader (from the transformation I guess)
> com.ctc.wstx.sr.ValidatingStreamReader@1e7daa2
>
> Could it be that TransforInInterceptor and JAXRSInterceptor are not
> compatible in regards of the message content?

Thanks for investigating further - please see the other message I just 
forwarded. Btw, I'm also on #cxf, in case you need a prompt answer

Sergey
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CXFRS-does-not-process-JSON-tp5716343p5716412.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: CXFRS does not process JSON

Posted by hom <tl...@sharklasers.com>.
I investigated further and found that in JAXRSUtils.processParameter the
statement

InputStream is = message.getContent(InputStream.class);

returns null.

If I look into the contents of the XMlMessage I see:

class org.apache.cxf.io.DelegatingInputStream
org.apache.cxf.transport.http.AbstractHTTPDestination$1@1963e55
interface javax.xml.stream.XMLStreamReader (from the transformation I guess)
com.ctc.wstx.sr.ValidatingStreamReader@1e7daa2

Could it be that TransforInInterceptor and JAXRSInterceptor are not
compatible in regards of the message content?




--
View this message in context: http://camel.465427.n5.nabble.com/CXFRS-does-not-process-JSON-tp5716343p5716412.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXFRS does not process JSON

Posted by hom <tl...@sharklasers.com>.
I managed to wire up the bus to the endpoint by adding bus="tb" to the bus
element.

But now I get a NullPointerException. It seems that the
TransformInInterceptor has problems transformig the message. Here is the
stack trace:

2012-07-24 15:30:57,905 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain           
| .cxf.phase.PhaseInterceptorChain  674 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Chain org.apache.cxf.phase.PhaseInterceptorChain@e2e59e was created.
Current flow:
  receive [LoggingInInterceptor, PolicyInInterceptor]
  pre-stream [CertConstraintsInterceptor]
  post-stream [TransformInInterceptor]
  unmarshal [JAXRSInInterceptor]
  pre-logical [OneWayProcessorInterceptor]
  invoke [ServiceInvokerInterceptor]
  post-invoke [OutgoingChainInterceptor]

2012-07-24 15:30:57,905 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain           
| .cxf.phase.PhaseInterceptorChain  259 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Invoking handleMessage on interceptor
org.apache.cxf.interceptor.LoggingInInterceptor@10d144e
2012-07-24 15:30:57,935 | INFO  | er/v1/json/doit/ | LoggingInInterceptor            
| eptor.AbstractLoggingInterceptor  233 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Inbound Message
----------------------------
ID: 1
Address: http://localhost:8181/cxf/xyz/json/doit/
Encoding: ISO-8859-1
Http-Method: POST
Content-Type: application/json
Headers: {Accept=[application/json], accept-encoding=[gzip,deflate],
Content-Length=[33], content-type=[application/json], Host=[localhost:8181],
User-Agent=[Jakarta Commons-HttpClient/3.1]}
Payload: {"DoItRequest":{"country":"DE"}}

--------------------------------------
2012-07-24 15:30:57,935 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain           
| .cxf.phase.PhaseInterceptorChain  259 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Invoking handleMessage on interceptor
org.apache.cxf.ws.policy.PolicyInInterceptor@688c5d
2012-07-24 15:30:57,935 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain           
| .cxf.phase.PhaseInterceptorChain  259 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Invoking handleMessage on interceptor
org.apache.cxf.transport.https.CertConstraintsInterceptor@1abf87e
2012-07-24 15:30:57,935 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain           
| .cxf.phase.PhaseInterceptorChain  259 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Invoking handleMessage on interceptor
org.apache.cxf.interceptor.transform.TransformInInterceptor@1d76e81
2012-07-24 15:30:59,157 | DEBUG | heckpoint Worker | MessageDatabase                 
| emq.store.kahadb.MessageDatabase 1349 | 196 -
org.apache.activemq.activemq-core - 5.6.0 | Checkpoint started.
2012-07-24 15:30:59,257 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain           
| .cxf.phase.PhaseInterceptorChain  259 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Invoking handleMessage on interceptor
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor@93660b
2012-07-24 15:30:59,317 | DEBUG | er/v1/json/doit/ | JAXRSUtils                      
| pache.cxf.jaxrs.utils.JAXRSUtils  234 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Trying to select a resource class, request path : /doit/
2012-07-24 15:30:59,347 | DEBUG | er/v1/json/doit/ | JAXRSUtils                      
| pache.cxf.jaxrs.utils.JAXRSUtils  296 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Trying to select a resource operation on the resource class
org.xyz.routes.json.Resource
2012-07-24 15:30:59,347 | DEBUG | er/v1/json/doit/ | JAXRSUtils                      
| pache.cxf.jaxrs.utils.JAXRSUtils  354 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Resource operation doit may get selected
2012-07-24 15:30:59,347 | DEBUG | er/v1/json/doit/ | JAXRSUtils                      
| pache.cxf.jaxrs.utils.JAXRSUtils  378 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Resource operation doit on the resource class
org.xyz.routes.json.Resource has been selected
2012-07-24 15:30:59,347 | DEBUG | er/v1/json/doit/ | JAXRSInInterceptor              
| s.interceptor.JAXRSInInterceptor  227 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Request path is: /doit/
2012-07-24 15:30:59,347 | DEBUG | er/v1/json/doit/ | JAXRSInInterceptor              
| s.interceptor.JAXRSInInterceptor  228 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Request HTTP method is: POST
2012-07-24 15:30:59,347 | DEBUG | er/v1/json/doit/ | JAXRSInInterceptor              
| s.interceptor.JAXRSInInterceptor  229 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Request contentType is: application/json
2012-07-24 15:30:59,357 | DEBUG | er/v1/json/doit/ | JAXRSInInterceptor              
| s.interceptor.JAXRSInInterceptor  230 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Accept contentType is: application/json
2012-07-24 15:30:59,357 | DEBUG | er/v1/json/doit/ | JAXRSInInterceptor              
| s.interceptor.JAXRSInInterceptor  232 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Found operation: doit
2012-07-24 15:30:59,377 | DEBUG | er/v1/json/doit/ | bind                            
| javax.xml.bind.ContextFinder      258 |  -  -  | Searching jaxb.properties
2012-07-24 15:30:59,377 | DEBUG | er/v1/json/doit/ | bind                            
| javax.xml.bind.ContextFinder      276 |  -  -  | Searching the system
property
2012-07-24 15:30:59,377 | DEBUG | er/v1/json/doit/ | bind                            
| javax.xml.bind.ContextFinder      284 |  -  -  | Searching
META-INF/services
2012-07-24 15:30:59,377 | DEBUG | er/v1/json/doit/ | bind                            
| javax.xml.bind.ContextFinder      299 |  -  -  | Unable to
load:META-INF/services/javax.xml.bind.JAXBContext
2012-07-24 15:30:59,377 | DEBUG | er/v1/json/doit/ | bind                            
| javax.xml.bind.ContextFinder      309 |  -  -  | Trying to create the
platform default provider
2012-07-24 15:30:59,377 | DEBUG | heckpoint Worker | MessageDatabase                 
| emq.store.kahadb.MessageDatabase 1484 | 196 -
org.apache.activemq.activemq-core - 5.6.0 | Checkpoint done.
2012-07-24 15:30:59,377 | DEBUG | er/v1/json/doit/ | ContextFactory                  
| m.sun.xml.bind.v2.ContextFactory  102 |  -  -  | Property
com.sun.xml.bind.XmlAccessorFactoryis not active.  Using JAXB's
implementation
2012-07-24 15:30:59,618 | DEBUG | er/v1/json/doit/ |
WebApplicationExceptionMapper    | pl.WebApplicationExceptionMapper   62 |
119 - org.apache.cxf.cxf-api - 2.6.1 | WebApplicationException has been
caught, status: 400, message: exception cause class:
java.lang.NullPointerException
javax.ws.rs.WebApplicationException: java.lang.NullPointerException
	at
org.apache.cxf.jaxrs.provider.json.JSONProvider.readFrom(JSONProvider.java:246)[130:org.apache.cxf.cxf-rt-rs-extension-providers:2.6.1]
	at
org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1038)[132:org.apache.cxf.cxf-rt-frontend-jaxrs:2.6.1]
	at
org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:614)[132:org.apache.cxf.cxf-rt-frontend-jaxrs:2.6.1]
	at
org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:578)[132:org.apache.cxf.cxf-rt-frontend-jaxrs:2.6.1]
	at
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:238)[132:org.apache.cxf.cxf-rt-frontend-jaxrs:2.6.1]
	at
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:89)[132:org.apache.cxf.cxf-rt-frontend-jaxrs:2.6.1]
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)[119:org.apache.cxf.cxf-api:2.6.1]
	at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122)[119:org.apache.cxf.cxf-api:2.6.1]
	at
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:211)[126:org.apache.cxf.cxf-rt-transports-http:2.6.1]
	at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213)[126:org.apache.cxf.cxf-rt-transports-http:2.6.1]
	at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154)[126:org.apache.cxf.cxf-rt-transports-http:2.6.1]
	at
org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:129)[126:org.apache.cxf.cxf-rt-transports-http:2.6.1]
	at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:187)[126:org.apache.cxf.cxf-rt-transports-http:2.6.1]
	at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:110)[126:org.apache.cxf.cxf-rt-transports-http:2.6.1]
	at
javax.servlet.http.HttpServlet.service(HttpServlet.java:713)[61:org.apache.geronimo.specs.geronimo-servlet_2.5_spec:1.1.2]
	at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:166)[126:org.apache.cxf.cxf-rt-transports-http:2.6.1]
	at
org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:547)[72:org.eclipse.jetty.servlet:7.5.4.v20111024]
	at
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:480)[72:org.eclipse.jetty.servlet:7.5.4.v20111024]
	at
org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:70)[82:org.ops4j.pax.web.pax-web-jetty:1.0.9]
	at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)[70:org.eclipse.jetty.server:7.5.4.v20111024]
	at
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520)[71:org.eclipse.jetty.security:7.5.4.v20111024]
	at
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)[70:org.eclipse.jetty.server:7.5.4.v20111024]
	at
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:941)[70:org.eclipse.jetty.server:7.5.4.v20111024]
	at
org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:117)[82:org.ops4j.pax.web.pax-web-jetty:1.0.9]
	at
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:409)[72:org.eclipse.jetty.servlet:7.5.4.v20111024]
	at
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)[70:org.eclipse.jetty.server:7.5.4.v20111024]
	at
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:875)[70:org.eclipse.jetty.server:7.5.4.v20111024]
	at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)[70:org.eclipse.jetty.server:7.5.4.v20111024]
	at
org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:72)[82:org.ops4j.pax.web.pax-web-jetty:1.0.9]
	at
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)[70:org.eclipse.jetty.server:7.5.4.v20111024]
	at
org.eclipse.jetty.server.Server.handle(Server.java:345)[70:org.eclipse.jetty.server:7.5.4.v20111024]
	at
org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:441)[70:org.eclipse.jetty.server:7.5.4.v20111024]
	at
org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:936)[70:org.eclipse.jetty.server:7.5.4.v20111024]
	at
org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:801)[66:org.eclipse.jetty.http:7.5.4.v20111024]
	at
org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:224)[66:org.eclipse.jetty.http:7.5.4.v20111024]
	at
org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)[70:org.eclipse.jetty.server:7.5.4.v20111024]
	at
org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)[65:org.eclipse.jetty.io:7.5.4.v20111024]
	at
org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)[65:org.eclipse.jetty.io:7.5.4.v20111024]
	at
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)[64:org.eclipse.jetty.util:7.5.4.v20111024]
	at
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)[64:org.eclipse.jetty.util:7.5.4.v20111024]
	at java.lang.Thread.run(Thread.java:662)[:1.6.0_24]
Caused by: java.lang.NullPointerException
	at
org.codehaus.jettison.AbstractXMLInputFactory.readAll(AbstractXMLInputFactory.java:122)[129:org.codehaus.jettison.jettison:1.3.1]
	at
org.codehaus.jettison.AbstractXMLInputFactory.createXMLStreamReader(AbstractXMLInputFactory.java:105)[129:org.codehaus.jettison.jettison:1.3.1]
	at
org.codehaus.jettison.AbstractXMLInputFactory.createXMLStreamReader(AbstractXMLInputFactory.java:93)[129:org.codehaus.jettison.jettison:1.3.1]
	at
org.apache.cxf.jaxrs.provider.json.utils.JSONUtils.createStreamReader(JSONUtils.java:159)[130:org.apache.cxf.cxf-rt-rs-extension-providers:2.6.1]
	at
org.apache.cxf.jaxrs.provider.json.JSONProvider.createReader(JSONProvider.java:264)[130:org.apache.cxf.cxf-rt-rs-extension-providers:2.6.1]
	at
org.apache.cxf.jaxrs.provider.json.JSONProvider.createReader(JSONProvider.java:254)[130:org.apache.cxf.cxf-rt-rs-extension-providers:2.6.1]
	at
org.apache.cxf.jaxrs.provider.json.JSONProvider.readFrom(JSONProvider.java:216)[130:org.apache.cxf.cxf-rt-rs-extension-providers:2.6.1]
	... 40 more
2012-07-24 15:30:59,658 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain           
| .cxf.phase.PhaseInterceptorChain  259 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Invoking handleMessage on interceptor
org.apache.cxf.interceptor.OneWayProcessorInterceptor@1768eb6
2012-07-24 15:30:59,658 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain           
| .cxf.phase.PhaseInterceptorChain  259 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Invoking handleMessage on interceptor
org.apache.cxf.interceptor.ServiceInvokerInterceptor@97d818
2012-07-24 15:30:59,658 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain           
| .cxf.phase.PhaseInterceptorChain  259 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Invoking handleMessage on interceptor
org.apache.cxf.interceptor.OutgoingChainInterceptor@ec4446
2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ |
OutgoingChainInterceptor         | rceptor.OutgoingChainInterceptor  176 |
119 - org.apache.cxf.cxf-api - 2.6.1 | Interceptors contributed by bus:
[org.apache.cxf.interceptor.LoggingOutInterceptor@1ba9eea,
org.apache.cxf.ws.policy.PolicyOutInterceptor@1173763,
org.apache.cxf.interceptor.transform.TransformOutInterceptor@1354d59]
2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ |
OutgoingChainInterceptor         | rceptor.OutgoingChainInterceptor  180 |
119 - org.apache.cxf.cxf-api - 2.6.1 | Interceptors contributed by service:
[]
2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ |
OutgoingChainInterceptor         | rceptor.OutgoingChainInterceptor  184 |
119 - org.apache.cxf.cxf-api - 2.6.1 | Interceptors contributed by endpoint:
[org.apache.cxf.interceptor.MessageSenderInterceptor@6913ce]
2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ |
OutgoingChainInterceptor         | rceptor.OutgoingChainInterceptor  190 |
119 - org.apache.cxf.cxf-api - 2.6.1 | Interceptors contributed by binding:
[org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor@9366ba]
2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain           
| .cxf.phase.PhaseInterceptorChain  205 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Adding interceptor
org.apache.cxf.interceptor.LoggingOutInterceptor@1ba9eea to phase pre-stream
2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain           
| .cxf.phase.PhaseInterceptorChain  205 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Adding interceptor
org.apache.cxf.ws.policy.PolicyOutInterceptor@1173763 to phase setup
2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain           
| .cxf.phase.PhaseInterceptorChain  205 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Adding interceptor
org.apache.cxf.interceptor.transform.TransformOutInterceptor@1354d59 to
phase pre-stream
2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain           
| .cxf.phase.PhaseInterceptorChain  205 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Adding interceptor
org.apache.cxf.interceptor.MessageSenderInterceptor@6913ce to phase
prepare-send
2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain           
| .cxf.phase.PhaseInterceptorChain  205 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Adding interceptor
org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor@9366ba to phase marshal
2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain           
| .cxf.phase.PhaseInterceptorChain  674 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Chain org.apache.cxf.phase.PhaseInterceptorChain@13d6bcb was
created. Current flow:
  setup [PolicyOutInterceptor]
  prepare-send [MessageSenderInterceptor]
  pre-stream [LoggingOutInterceptor, TransformOutInterceptor]
  marshal [JAXRSOutInterceptor]

2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ | PhaseInterceptorChain           
| .cxf.phase.PhaseInterceptorChain  259 | 119 - org.apache.cxf.cxf-api -
2.6.1 | Invoking handleMessage on interceptor
org.apache.cxf.ws.policy.PolicyOutInterceptor@1173763
2012-07-24 15:30:59,698 | DEBUG | er/v1/json/doit/ | PolicyOutInterceptor            
| f.ws.policy.PolicyOutInterceptor   63 | 119 - org.apache.cxf.cxf-api -
2.6.1 | No binding operation info.
2012-07-

Do you have an idea what could be wrong here?



--
View this message in context: http://camel.465427.n5.nabble.com/CXFRS-does-not-process-JSON-tp5716343p5716403.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXFRS does not process JSON

Posted by hom <tl...@sharklasers.com>.
I added a bus to the blueprint context file like this:

<cxf:bus id="tb" name="transformBus">
    <cxf:features>
        <ref component-id="transformFeature"/>
    </cxf:features>
</cxf:bus>

After deployment JConsole reveals that the bus is present.

Now I want to wire up the bus to the endpoint like this:
from("cxfrs:///xyz/json?bus=#tb&resourceClasses=" +
Resource.class.getName())

This fails as the bus can not be found in the Camel registry.

Both of the following statements return nothing:
Object ret =
exchange.getContext().getRegistry().lookupByType(org.apache.cxf.Bus.class);
Object ret1 = exchange.getContext().getRegistry().lookup("tb");

The other beans, e.g. transformFeature are available in the Camel registry.

Do you have an idea why the bus is not available in the Camel registry?





--
View this message in context: http://camel.465427.n5.nabble.com/CXFRS-does-not-process-JSON-tp5716343p5716381.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXFRS does not process JSON

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 23/07/12 17:52, hom wrote:
> Thanks for the quick reply. I added the transformFeature bean, but it seems
> that is has no effect.
> I am still getting the same message.
> This is what I did in the blueprint context:
>
> <blueprint>
>
>    <bean id="providerRoute" class="org.xyz.ProviderRoute"/>
>
>    <bean id="transformFeature"
> class="org.apache.cxf.feature.StaxTransformFeature">
>      <property name="inTransformElements">
>         <map>
>            <entry key="DoItRequest"
> value="{http://www.xyz.org/types}DoItRequest"/>
>         </map>
>      </property>
>    </bean>
> 		
>   <camelContext id="camel" xmlns="http://camel.apache.org/schema/blueprint">
>      <routeBuilder ref="providerRoute" />
>   </camelContext>
> </blueprint>
>
> Did I miss something?

It's a CXF-specific feature so it needs to bound to either a 
cxfrs:rsServer or jaxrs:endpoint (assuming a camel transport is used), 
using a "feature" extension.

Cheers, Sergey
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CXFRS-does-not-process-JSON-tp5716343p5716352.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: CXFRS does not process JSON

Posted by hom <tl...@sharklasers.com>.
Thanks for the quick reply. I added the transformFeature bean, but it seems
that is has no effect.
I am still getting the same message.
This is what I did in the blueprint context:

<blueprint>

  <bean id="providerRoute" class="org.xyz.ProviderRoute"/>

  <bean id="transformFeature"
class="org.apache.cxf.feature.StaxTransformFeature">
    <property name="inTransformElements">
       <map>
          <entry key="DoItRequest"
value="{http://www.xyz.org/types}DoItRequest"/>
       </map>
    </property>
  </bean>
		 
 <camelContext id="camel" xmlns="http://camel.apache.org/schema/blueprint">
    <routeBuilder ref="providerRoute" />
 </camelContext>
</blueprint>

Did I miss something?



--
View this message in context: http://camel.465427.n5.nabble.com/CXFRS-does-not-process-JSON-tp5716343p5716352.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXFRS does not process JSON

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 23/07/12 16:10, hom wrote:
> Hi,
>
> I've created a cxfrs route as described in
> http://camel.apache.org/cxfrs.html (How to consume the REST request in
> Camel). I am using SOAPUI to test the endpoint. The resource class is:
>
> /@Path("/")
> @Consumes({"application/xml","application/json"})
> @Produces({"application/xml","application/json"})
> public class Resource {
>
> 	@POST
> 	@Path("/doit/")
> 	@Consumes({"application/xml","application/json"})
> 	@Produces({"application/xml","application/json"})
>      public DoItResponse doit(DoItRequest request){return null;};
> }/
>
> For XML everything works fine, but when I send a json request I always get:
>
> <data contentType="text/plain" contentLength="555"><![CDATA[JAXBException
> occurred : unexpected element (uri:"", local:"DoItRequest"). Expected
> elements are
> <{http://www.xyz.org/types}DoItRequest>,<{http://www.xyz.org/types}DoItResponse>,<{http://www.xyz.org/types}
> ProviderError>. unexpected element (uri:"", local:"DoItRequest") ...
>
> I set media type and access header to application/json, but it seems that
> json is not recognized.
> Any ideas?
>
The problem is most likely to do with the fact that DoItRequest is 
namespace-qualified (with @XmlRootElement or at the package level).
However a json sequence you are posting is most likely has no prefixes.
If you work with Jettison, then one way to do it is to provide a 
namespace map, however, as I said I think the sequence have no prefixes 
so there's no inbound info that can be used to map prefixes to namespaces.
Thus the better option is to use a transformation feature:
http://cxf.apache.org/docs/transformationfeature.html

having an 'inTransformElements' property to have a pair like 
"DoItRequest": "{http//mynamespace}DoItRequest" should do it

HTH, Sergey
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CXFRS-does-not-process-JSON-tp5716343.html
> Sent from the Camel - Users mailing list archive at Nabble.com.