I have been putting efforts in understanding this error. I have gone through most of the questions related to this and I am not clear as most of them addressed how to solve it. I want to understand what error is and why is it coming . Please help me in understanding below :
- Why does spring look into current thread for the scope "session" ? Does spring store all the request attributes and session attributes in the thread context ?
2.I recieve this error inconsistently. If it is an issue, it should come all the times. Below is my code snippet.
-- Application context
<bean id="location" class="com.mindtree.ruc.cmn.utils.LoginLocation" scope="session"> <aop:scoped-proxy/> </bean> <bean id="homePageRH" class="com.rsaame.pas.home.ui.HomePageRH"> <property name="location" ref="location" /> </bean> -- web.xml
<listener> <listener-class> org.springframework.web.context.request.RequestContextListener </listener-class> </listener> -- logs:
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.rsaame.pas.dao.cmn.PASStoredProcedure]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.location': 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. at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:108) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280) ... 42 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.location': 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. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:341) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192) at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:33) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.getTarget(Cglib2AopProxy.java:653) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:604)