Http Grails未找到线程绑定请求

Http Grails未找到线程绑定请求,http,grails,Http,Grails,我使用Grails服务闭包对另一个web应用程序执行异步HTTP请求。使用grails1.3.9,我在这方面非常有限。代码在线程中运行。它是从计划作业和多个函数调用调用的。我得到的错误如下: 错误: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processin

我使用Grails服务闭包对另一个web应用程序执行
异步HTTP请求。使用
grails1.3.9
,我在这方面非常有限。代码在线程中运行。它是从计划作业和多个函数调用调用的。我得到的错误如下:

错误:

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.
代码:


但是两者都没有帮助

这是一个没有很好的文档记录的东西,或者你可以向你发送螺旋:

尝试:

您需要在build.gradle中进行spring测试

  compile 'org.springframework:spring-test:2.5'
有一个Grails2分支,因此如果它是Grails2,则在另一个分支中遵循相同的类

    <listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    listener.add = true
listener.classNames = ["org.springframework.web.context.request.RequestContextListener"]
/*
* Fix for No thread-bound request found: Are you referring to request attributes
*/
def webRequest = RequestContextHolder.getRequestAttributes()
if(!webRequest) {
    def servletContext  = ServletContextHolder.getServletContext()
    def applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext)
    webRequest =  grails.util.GrailsWebMockUtil.bindMockWebRequest(applicationContext)
}
  compile 'org.springframework:spring-test:2.5'