This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm creating a spring portlet and in the controller we try to inject a bean which needs to be created for every request ( Request scope ).
The controller code looks like this
and in the beans configuration xml
This is error which i receive, do i need to make any other configuration to get this work?
Error creating bean with name 'controller' defined in PortletContext resource [/WEB-INF/controller-portlet.xml]: Cannot resolve reference to bean 'test' while setting bean property 'test'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'test': Scope 'request' 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.
PS : All works if i remove the scope attribute
Joined: Feb 07, 2007
I've got it fixed by adding the RequestContextListener in the web.xml
But still the constructor of the bean defined with request scope is called only once, while i would want to see it created for every request.