【发布时间】:2016-05-11 22:37:24
【问题描述】:
我有一个调用 joda taglib 的石英作业(但可以是任何其他的)。
我是这样做的:
def joda = grailsApplication.mainContext.getBean('grails.plugin.jodatime.taglib.FormattingTagLib')
def formatDate = joda.format(value:event.startDate, style:"SS", locale:user.locale, zone:user.timeZone)
但我明白了:
org.quartz.JobExecutionException: 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. [See nested exception: 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.]
这绝对是有道理的,因为石英作业不受请求约束,因为它是由时间触发的,而不是由请求触发的。
我四处寻找,但找不到合适的解决方案。有人可以给我提示吗?
【问题讨论】: