title: Using Session Scope in Spring Beans
body: <p>I'm using JSF 2 for the view and Spring for the business logic. I'm trying to set a session scope to one of my spring beans using annotations(@Scope("session")), but I'm getting this exception:</p>
  
  <pre><code>    SEVERE: Context initialization failed
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'handleFiles': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private creazione.util.FTPOperations creazione.components.HandleOldFiles.operations; 
  nested exception is org.springframework.beans.factory.BeanCreationException: 
  Error creating bean with name 'ftpOperations': 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.
  </code></pre>
  
  <p>I know about RequestContextListener. It's in my web.xml. I've also added RequestContextFilter:</p>
  
  <pre><code>&lt;listener&gt;
          &lt;listener-class&gt;
              org.springframework.web.context.ContextLoaderListener
          &lt;/listener-class&gt;
      &lt;/listener&gt;
      &lt;listener&gt;
          &lt;listener-class&gt;
              org.springframework.web.context.request.RequestContextListener
          &lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;filter&gt;
          &lt;filter-name&gt;requestContextFilter&lt;/filter-name&gt;
          &lt;filter-class&gt;org.springframework.web.filter.RequestContextFilter&lt;/filter-class&gt;
      &lt;/filter&gt;
  
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;requestContextFilter&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
          &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;
          &lt;dispatcher&gt;INCLUDE&lt;/dispatcher&gt;
          &lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt;
      &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>Nothing seems to work. What am I doing wrong?
  Thank you!</p>