aspose file tools*
The moose likes Spring and the fly likes Spring Portlet - Bean scope error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring Portlet - Bean scope error" Watch "Spring Portlet - Bean scope error" New topic
Author

Spring Portlet - Bean scope error

Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 185
Hello,

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

Thanks
Srikkanth

Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 185
Hello all,
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.

Thanks
Srikkanth
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring Portlet - Bean scope error