title: 'No thread-bound request found' in filter under Grails 2.0
body: <p>I'm developing an Grails plugin, that have filter, with code like:</p>
  
  <pre><code>void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, javax.servlet.FilterChain chain) {
  
      HttpServletRequest request = servletRequest
      HttpServletResponse response = servletResponse
      String url = request.requestURI.substring(request.contextPath.length())
      logger.debug("Processing url: $url")
      chain.doFilter(servletRequest, servletResponse)
  }
  </code></pre>
  
  <p>pretty standard Java EE filter, that extends spring's <code>GenericFilterBean</code>. And it's registered by <code>SpringSecurityUtils.registerFilter %NAME%, %POS%</code> (it's spring security extension)</p>
  
  <p>After upgrading to Grails 2.0 I start getting some strange errors, on <code>chain.doFilter()</code> line:</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 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>Notice that everything fine at <code>String url = request.requestURI.....</code> line. And displayed url is valid.</p>
  
  <p>The problem that this error unpredictable :( sometimes filter is working fine, sometimes throws exception, and I can't figure out what the problem, and what I must do to fix it. Probably it depends on order of bean's initialization, but i'm not sure</p>
  
  <hr>
  
  <p><strong>Update</strong>: found that it's because of <code>resources</code> plugin. Error gone after removing this plugin. Not sure that it's a best way.</p>