I'm having difficulties with a new session-scoped bean I've created, userPreferences. I get the following lengthy exception when I try to autowire it one of my Controllers:
I've defined the userPreferences bean as follows:org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'welcomeController': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Could not autowire field: com.foo.web.UserPreferences com.foo.web.WelcomeController.userPreferences; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'userPreferences': 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.
And I autowired it into my Controller as followsCode:@Component @Scope("session") public class UserPreferences { ... }
I configured my dispatcherServlet.xml with the following to recognize annotations:Code:@Controller public class WelcomeController { @Autowired UserPreferences userPreferences; }
Any ideas what I'm missing?Code:<context:annotation-config /> <context:component-scan base-package="com.foo.web"/>


Reply With Quote