0

I define a bean with scope request and get an error when i start my application:

"Cannot resolve reference to bean 'accountDS' while setting bean property 'accountDS'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountDS': 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"

I am using this bean from within my controller which is a singleton. Is this why i can't get a request? If so how can i create a scoped proxy? I also have RequestContextListener in my web.xml but it doesn't help.

    <listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
TastyCode
  • 5,679
  • 4
  • 37
  • 42

1 Answers1

4
<bean id="..." class="..." scope="request">
<aop:scoped-proxy />
</bean>
pap
  • 27,064
  • 6
  • 41
  • 46
  • You can also do this with the @Scope annotation: http://stackoverflow.com/questions/4503606/annotation-equivalent-of-aopscoped-proxy – etherous Dec 06 '16 at 20:54