dev@jersey.java.net

Re: [Jersey] null pointer exception on resource class access HttpServletRequest?

From: James Russo <jr_at_halo3.net>
Date: Wed, 21 Apr 2010 11:29:39 -0400

On Apr 21, 2010, at 11:18 AM, Paul Sandoz wrote:

> Yes. Method parameters, for methods that Jersey invokes, are independent of the scope of the class. Setter methods and fields are not. But in this case Jersey will inject a thread local proxy for HttpServletRequest so you can use it with singleton-scoped classes.

Understood. So, if I have a @Context HttpServletRequest as a class variable, the @Scope will need to be request based.

> IIRC if your beans are managed by Spring then by default they are singletons.

They are. So, when you said it wasn't possible to not have a request, is it possible within the context of spring? When we aren't using the Jersey filter, but rather the com.sun.jersey.spi.spring.container.servlet.SpringServlet? Somehow I am getting null for request object.

-jr