title: How to enable request scope in async task executor
body: <p>In my app I have some async web services. Server accept request, return OK response and start processing request with AsyncTaskExecutor. My question is how to enable request scope here because in this processing I need to get class which is annotated by:</p>
  
  <pre><code>@Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS)
  </code></pre>
  
  <p>Now I get exception:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.requestContextImpl': 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>because it runs in <code>SimpleAsyncTaskExecutor</code> and not in <code>DispatcherServlet</code></p>
  
  <p>my async processing of request</p>
  
  <pre><code>taskExecutor.execute(new Runnable() {
  
      @Override
      public void run() {
          asyncRequest(request);
      }
  });
  </code></pre>
  
  <p>where taskExecutor is:</p>
  
  <pre><code>&lt;bean id="taskExecutor" class="org.springframework.core.task.SimpleAsyncTaskExecutor" /&gt;
  </code></pre>