Sergey Beryozkin wrote:
> 
> The only JAX-RS standard way to get UriInfo (or any other @Context
> annotated) values into subresources is to inject them as method parameters
> :
> ...
> Perhaps we'll need to come up with some sort of CXF-private subresource
> injection technique - Jersey does some tricks in this regard I believe.
> 

Thank for the very fast reply!
First some words on CXF-private sub-resource injection: Personally, I
usually do not advocate solutions that deviate from standards.

Second, to my problem: I tried to move the UriInfo injection to a method
parameter in all the methods where I need an UriInfo object.
It works well for everything except when I try to retrieve a sub-resource,
in which case I get an exception like this:
Sep 18, 2008 10:38:30 AM org.apache.cxf.phase.PhaseInterceptorChain
doIntercept
INFO: Interceptor has thrown exception, unwinding now
java.lang.NullPointerException
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:148)
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:63)
        at
org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:56)
        at
org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
        at
org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:92)
        at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
        at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78)
        at
org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:92)
        at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:283)
        at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:128)
        at
org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:174)
        at
org.apache.cxf.transport.servlet.AbstractCXFServlet.doGet(AbstractCXFServlet.java:156)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at 
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:613)
Sep 18, 2008 10:38:30 AM
org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
INFO: Outbound Message

The code in my sub-resource class is never even executed, the exception
happens in CXF.

My next attempt will be to forward the UriInfo received by the sub-resources
parent to the sub-resource. I'll get back on how that works.
-- 
View this message in context: 
http://www.nabble.com/UriInfo-object-in-Sub-Resource-tp19533573p19545081.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to