views:

34

answers:

1

I've created a RESTful web service using spring. I have controllers that are session scoped.

When i try to perform a GET request it actually works great but i get an ignored exception while DispatcherServlet tries to determine Last-Modified value.

2010-10-28 11:32:50,487 [http-8080-2] DEBUG org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'Spring MVC Dispatcher Servlet' determining Last-Modified value for [/apm/users/1009]

2010-10-28 11:32:50,491 [http-8080-2] DEBUG org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Matching patterns for request [/users/1009] are [/users/{id}]

2010-10-28 11:32:50,491 [http-8080-2] DEBUG org.springframework.web.servlet.DispatcherServlet - Exception thrown in getLastModified org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.userController': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:339)

POST requests also works but i don't get any exception when i run them.

Any idea why it happens ?! What can i do to prevent that ?!

Thanks !

+2  A: 

It was a bug in Spring (SPR-7456), fixed in Spring 3.0.4.

As a workaround for previous versions you probably can add

<listener>org.springframework.web.context.request.RequestContextListener</listener>

to your web.xml.

axtavt
Good catch.....
skaffman
i upgraded to 3.0.4. thanks !
Rafa
@Rafa: 3.0.5 came out yesterday. If you're going to upgrade, upgrade to that.
skaffman
i will. thanks !
Rafa