camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: Questions about cxfrs
Date Wed, 22 Jan 2014 10:19:31 GMT
The stack trace suggests that JacksonJsonProvider did have a thread 
local context representing JAX-RS Providers injected into it at the 
registration time but at the invocation time no thread-local entry has 
been added to it and hence NPE.
I have a lot of tests in CXF where client-side providers have the 
contexts injected, so I think it is somehow related to the way the 
client invocation is managed by cxfrs.
I'm just curious how to reproduce it. Is there any chance that you can 
create a basic test project ? I will try to reproduce it on my own too

Sergey


On 22/01/14 03:51, David wrote:
> On Tue, Jan 21, 2014 at 8:16 PM, Willem Jiang <willem.jiang@gmail.com>wrote:
>
>>
>> On January 22, 2014 at 5:14:40 AM, David (wakarimasen@gmail.com) wrote:
>>>> When my route attempts to invoke Service2, the URI is set to:
>>> http://localhost:8080/service2/service2path/service1/service1path,
>>> where
>>> service1/service1path is configured in my.Service1. I'm also
>>> not sure why
>>> I'm providing a serviceClass for rsClient. I thought maybe it
>>> was going to
>>> instantiate my service, but that doesn't seem to be the case.
>>>
>>
>> If you routing the response of first service to second service, you may
>> need to clean up the CamelHttpPath message header.
>>
>>
> Thanks, that was very helpful, but I'm not quite there yet. Shouldn't this
> header be cleared when I set inheritHeaders to false?
>
> I had made both the first and second service have the same http path in
> order to trick the camel route into working, and initially removing the
> header had the desired effect -- I.e.I got a 404 response because the path
> for the second service had been truncated. However, when I changed the
> entry-point service back to its original path, I got an NPE (at
> org.apache.cxf.jaxrs.impl.tl.ThreadLocalProviders.getContextResolver(ThreadLocalProviders.java:50)).
> I fixed that by instead setting the CamelHttpPath to the path for the next
> service, which worked.
>
> Next, I added in the third service, by wiring a second rsClient for it and
> duplicating the setHeader and cxfrs producer endpoint in the camel route.
> This mostly works, but not quite. When the response comes back from
> service2, my object is populated as expected. However, by the time the call
> to service3 happens, all variables in the object have been set to 0 for the
> int and null for the strings. Service3 is then called with this empty
> object and returns. Finally, I again get the same NPE from Service1. I
> tried resetting the CamelHttpPath to the initial value, but that didn't fix
> the NPE. Removing Service3 also doesn't fix the NPE during the Service1
> response, and the variables in the object are also still reset to 0/null.
>
> Here's my route, as it stands now:
>
> <from uri="cxfrs:bean:Service1"/>
> <setHeader headerName="CamelHttpPath">
> <simple>/service2/service2path</simple> </setHeader> <to
> uri="cxfrs:bean:Service2"/>
> <setHeader headerName="CamelHttpPath">
> <simple>/service3/service3path</simple> </setHeader>
> <to uri="cxfrs:bean:Service3"/>
> <to uri="log:response"/>
>
> The same NPE I'm seeing was also seen here, apparently:
>
> http://mail-archives.apache.org/mod_mbox/cxf-users/201311.mbox/%3C52987699.6040108@gmail.com%3E
>
> Here's a more complete stacktrace from my logs:
>
> --------------------------------------
> 22:38:54,309 | INFO  | tp2013341004-662 | response
> | 134 - org.apache.camel.camel-core | Exchange[ExchangePattern: InOut,
> BodyType: mycompany.MyObject, Body:
> {"myobject":{"id":0,"value1":null,"value2":null,"value3":0}}]
> 22:38:54,311 | WARN  | tp2013341004-662 | PhaseInterceptorChain
>   | 150 - org.apache.cxf.cxf-api - 2.7.0 | Interceptor for {
> http://myservice.mycompany.com/}Service1 has thrown exception, unwinding now
> javax.ws.rs.InternalServerErrorException: java.lang.NullPointerException
> at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleWriteException(JAXRSOutInterceptor.java:396)[166:org.apache.cxf.cxf-rt-frontend-jaxrs:2.7.0]
> at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:305)[166:org.apache.cxf.cxf-rt-frontend-jaxrs:2.7.0]
> at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:155)[166:org.apache.cxf.cxf-rt-frontend-jaxrs:2.7.0]
> at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:86)[166:org.apache.cxf.cxf-rt-frontend-jaxrs:2.7.0]
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)[150:org.apache.cxf.cxf-api:2.7.0]
> at
> org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77)[150:org.apache.cxf.cxf-api:2.7.0]
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)[150:org.apache.cxf.cxf-api:2.7.0]
> at
> org.apache.cxf.phase.PhaseInterceptorChain.resume(PhaseInterceptorChain.java:242)[150:org.apache.cxf.cxf-api:2.7.0]
> at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78)[150:org.apache.cxf.cxf-api:2.7.0]
> at
> org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:355)[176:org.apache.cxf.cxf-rt-transports-http-jetty:2.7.0]
> at
> org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:319)[176:org.apache.cxf.cxf-rt-transports-http-jetty:2.7.0]
> at
> org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72)[176:org.apache.cxf.cxf-rt-transports-http-jetty:2.7.0]
> at
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1077)[93:org.eclipse.jetty.aggregate.jetty-all-server:8.1.9.v20130131]
> at
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1013)[93:org.eclipse.jetty.aggregate.jetty-all-server:8.1.9.v20130131]
> at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)[93:org.eclipse.jetty.aggregate.jetty-all-server:8.1.9.v20130131]
> at
> org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:193)[93:org.eclipse.jetty.aggregate.jetty-all-server:8.1.9.v20130131]
> at
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)[93:org.eclipse.jetty.aggregate.jetty-all-server:8.1.9.v20130131]
> at
> org.eclipse.jetty.server.Server.handleAsync(Server.java:408)[93:org.eclipse.jetty.aggregate.jetty-all-server:8.1.9.v20130131]
> at
> org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:493)[93:org.eclipse.jetty.aggregate.jetty-all-server:8.1.9.v20130131]
> at
> org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:943)[93:org.eclipse.jetty.aggregate.jetty-all-server:8.1.9.v20130131]
> at
> org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1004)[93:org.eclipse.jetty.aggregate.jetty-all-server:8.1.9.v20130131]
> at
> org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861)[93:org.eclipse.jetty.aggregate.jetty-all-server:8.1.9.v20130131]
> at
> org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)[93:org.eclipse.jetty.aggregate.jetty-all-server:8.1.9.v20130131]
> at
> org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)[93:org.eclipse.jetty.aggregate.jetty-all-server:8.1.9.v20130131]
> at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)[93:org.eclipse.jetty.aggregate.jetty-all-server:8.1.9.v20130131]
> at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)[93:org.eclipse.jetty.aggregate.jetty-all-server:8.1.9.v20130131]
> at
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)[93:org.eclipse.jetty.aggregate.jetty-all-server:8.1.9.v20130131]
> at
> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)[93:org.eclipse.jetty.aggregate.jetty-all-server:8.1.9.v20130131]
> at java.lang.Thread.run(Thread.java:744)[:1.7.0_45]
> Caused by: java.lang.NullPointerException
> at
> org.apache.cxf.jaxrs.impl.tl.ThreadLocalProviders.getContextResolver(ThreadLocalProviders.java:50)[166:org.apache.cxf.cxf-rt-frontend-jaxrs:2.7.0]
> at
> org.codehaus.jackson.jaxrs.JacksonJsonProvider.locateMapper(JacksonJsonProvider.java:633)[245:jackson-jaxrs:1.9.10]
> at
> org.codehaus.jackson.jaxrs.JacksonJsonProvider.writeTo(JacksonJsonProvider.java:500)[245:jackson-jaxrs:1.9.10]
> at
> org.apache.cxf.jaxrs.utils.JAXRSUtils.writeMessageBody(JAXRSUtils.java:1317)[166:org.apache.cxf.cxf-rt-frontend-jaxrs:2.7.0]
> at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:282)[166:org.apache.cxf.cxf-rt-frontend-jaxrs:2.7.0]
> ... 27 more
> 22:38:54,312 | INFO  | tp2013341004-662 | LoggingOutInterceptor
>   | 150 - org.apache.cxf.cxf-api - 2.7.0.redhat-610139 | Outbound Message
>

Mime
View raw message