title: Error creating bean with name : Scope 'request' is not active for the current thread
body: <p>I have integrated SWF 2.2.1,Primefaces 2.2.1,JSF 2,Spring Security 3,Spring 3.1.0M1I and EhCache and AspectJ and Castor.</p>
  
  <p>I have defined beans for castor in my app-config.xml like </p>
  
  <pre><code>&lt;bean id="oXMapper" class="com.abc.xyz.util.OXMapper"&gt;
      &lt;property name="unmarshaller" ref="unmarshaller" /&gt;
      &lt;property name="marshaller" ref="marshaller" /&gt;
      &lt;property name="acordRequest" ref="acordRequest" /&gt;
      &lt;property name="acordResponse" ref="acordResponse" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="unmarshaller" class="org.springframework.oxm.castor.CastorMarshaller"&gt;
      &lt;property name="mappingLocation"
          value="classpath:/templates/mapping/ACORD_Response_Mapping.xml" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="marshaller" class="org.springframework.oxm.castor.CastorMarshaller"&gt;
      &lt;property name="mappingLocation"
          value="classpath:/templates/mapping/ACORD_Request_Mapping.xml" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="acordRequest" class="com.abc.xyz.cate.domain.ACORD"&gt;
      &lt;property name="insuranceSvcRq" ref="insuranceSvcRq" /&gt;
      &lt;property name="signonRq" ref="CltSearch_signonRq" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>I have a search page from where I am building the parameters like </p>
  
  <pre><code>&lt;h:panelGrid&gt;
      &lt;h:selectOneRadio id="#{msg.srchType}" value="#{acordRequest.insuranceSvcRq.com_csc_ClientSearchRq.com_csc_SearchInfo.com_csc_SearchCriteria.com_csc_ClientSearch.com_csc_SearchNameByType}"&gt;
          &lt;f:selectItem itemLabel="#{msg.exact}" itemValue="E" id="#{msg.exact}" /&gt;
      &lt;f:selectItem itemLabel="#{msg.phonetic}" itemValue="S" id="#{msg.phonetic}" /&gt;
      &lt;f:selectItem itemLabel="#{msg.truncated}" itemValue="P" id="#{msg.truncated}" /&gt;
          &lt;/h:selectOneRadio&gt;
  &lt;/h:panelGrid&gt;
  </code></pre>
  
  <p>Using Spring Webflow, I am calling the OXMapper functions and passing the ACORD(hierarchical structural as it is used to build xml) object to it. This OXMapper class is responsible for marshalling and unmarshalling of the object and xml respectively.</p>
  
  <p>Now the problem is whenever I am searching again on search page , old values automatically populates inside the fields.</p>
  
  <p>So I tried changing the scope to <strong>"Request"</strong>.</p>
  
  <pre><code>&lt;bean id="acordRequest" class="com.abc.xyz.cate.domain.ACORD"
      scope="request"&gt;
      &lt;property name="insuranceSvcRq" ref="insuranceSvcRq" /&gt;
      &lt;property name="signonRq" ref="CltSearch_signonRq" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>After changing the scope I get the following error:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'oXMapper' defined in ServletContext resource [/WEB-INF/config/app-config.xml]: Cannot resolve reference to bean 'acordRequest' while setting bean property 'acordRequest'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'acordRequest': 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.
  </code></pre>
  
  <p>My web.xml is as follows</p>
  
  <pre><code>&lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;
          /WEB-INF/config/web-application-config.xml
      &lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;error-page&gt;
      &lt;error-code&gt;500&lt;/error-code&gt;
      &lt;location&gt;/error.xhtml&lt;/location&gt;
  &lt;/error-page&gt;
  &lt;context-param&gt;
      &lt;param-name&gt;javax.faces.DEFAULT_SUFFIX&lt;/param-name&gt;
      &lt;param-value&gt;.xhtml&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;context-param&gt;
      &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;/param-name&gt;
      &lt;param-value&gt;Development&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;context-param&gt;
      &lt;param-name&gt;facelets.DEVELOPMENT&lt;/param-name&gt;
      &lt;param-value&gt;true&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;context-param&gt;
      &lt;param-name&gt;javax.faces.FACELETS_REFRESH_PERIOD&lt;/param-name&gt;
      &lt;param-value&gt;1&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;context-param&gt;
      &lt;param-name&gt;javax.faces.FACELETS_LIBRARIES&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/springsecurity.taglib.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;!-- Enables Spring Security --&gt;
  &lt;filter&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;springSecurityFilterChain&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;
  &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;listener&gt;
      &lt;listener-class&gt;
          org.springframework.security.web.session.HttpSessionEventPublisher&lt;/listener-class&gt;
  &lt;/listener&gt;
  &lt;servlet&gt;
      &lt;servlet-name&gt;Spring MVC Dispatcher Servlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Spring MVC Dispatcher Servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/certs/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;servlet&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.faces&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  </code></pre>
  
  <p></p>
  
  <p>My faces-config.xml has nothing as such</p>
  
  <pre><code>&lt;faces-config xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
  version="2.0"&gt;
  
  &lt;application&gt;
      &lt;!-- &lt;message-bundle&gt;JsfMessageResources&lt;/message-bundle&gt; --&gt;
  &lt;/application&gt;
  &lt;!-- JSF 2.0 Version of this faces-config.xml file --&gt;
  </code></pre>
  
  <p></p>