This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring Portlet - Bean scope error

 
Srikkanth Mohanasundaram
Ranch Hand
Posts: 242
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 242
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic