title: Grails No thread-bound request found when accessing request/session from thread
body: <p>I'm working with Grails 2.5.6.</p>
  
  <p>I have a list of tasks that previously were executed in series and needed to reference a "lang" attribute I have on the session.</p>
  
  <p>Now from the controller I call a class that creates threads, one per each tasks to accelerate the execution. After I added the threads, this error started to appear when the code tries to access the session:</p>
  
  <pre><code>No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the o
  riginally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outs
  ide of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
  </code></pre>
  
  <p>I believe there is something that needs to be setup in the threads I create to be able to access the request/session, but couldn't find any documentation.</p>
  
  <p>The way the session is accessed is:</p>
  
  <pre><code>RequestContextHolder.currentRequestAttributes().session.lang
  </code></pre>
  
  <p>This worked OK before adding the threads.</p>
  
  <p>Any ideas of what I need to do for that line of code to work on a new thread?</p>
  
  <p>BTW I tried two ways of creating the threads, the classic Thread.start / treads*.join() and using grails.async.Promises (<a href="http://docs.grails.org/2.5.6/guide/async.html" rel="nofollow noreferrer">http://docs.grails.org/2.5.6/guide/async.html</a>). On both I get the same error message.</p>