title: Better understanding of error : Scope 'session' is not active for the current thread
body: <p>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 :</p>
  
  <ol>
  <li>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 ?</li>
  </ol>
  
  <p>2.I recieve this error inconsistently. If it is an issue, it should come all the times. 
  Below is my code snippet.</p>
  
  <p>-- Application context</p>
  
  <pre><code>&lt;bean id="location" class="com.mindtree.ruc.cmn.utils.LoginLocation" scope="session"&gt;
          &lt;aop:scoped-proxy/&gt;
      &lt;/bean&gt;
      &lt;bean id="homePageRH" class="com.rsaame.pas.home.ui.HomePageRH"&gt;
          &lt;property name="location" ref="location" /&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>-- web.xml</p>
  
  <pre><code> &lt;listener&gt;
      &lt;listener-class&gt;
        org.springframework.web.context.request.RequestContextListener
      &lt;/listener-class&gt;
    &lt;/listener&gt;
  </code></pre>
  
  <p>-- logs:</p>
  
  <pre><code>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)
  </code></pre>