dev@jersey.java.net

null pointer exception on resource class access HttpServletRequest?

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

Hello Everyone,

        I am getting a null pointer exception while trying to use jersey and spring. I think it has something to do with the resource class being "singleton" scoped. I am using: 1.1.5.1

java.lang.NullPointerException
        at com.sun.jersey.server.impl.application.WebApplicationContext.getProperties(WebApplicationContext.java:114)
        at com.sun.jersey.server.impl.resource.PerRequestFactory.destroy(PerRequestFactory.java:75)
        at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:943)

I have the RequestContextListener in my web.xml..

I have my resource class with @Scope("singleton") and then I have some resource methods which the following as a parameter:

@Context HttpServletRequest req

So, I would think that the class can be singleton since the request is coming via a method parameter. I need the request object to get at some header values. I have tried changing to @Scope("request"), but it has the same result.

Anyone point me in the right direction here before I waste all day on this?

thanks,

-jr