【发布时间】:2012-11-22 12:33:51
【问题描述】:
我在 Grails 中编写了一个应用程序,但我在使用石英时遇到了一些问题。 我想从数据库中获取用户,然后再获取他的服务器。 如果有任何服务器我想检查每个服务器上的 PING 命令,但我收到这样的消息:
" [quartzScheduler_Worker-1] 错误 listeners.ExceptionPrinterJobListener - 作业中发生异常: GRAILS_JOBS。 消息:java.lang.IllegalStateException:未找到线程绑定请求:您指的是实际之外的请求属性 Web 请求,或处理原始请求之外的请求 接收线程?如果您实际上是在 Web 请求中操作 仍然收到此消息,您的代码可能在外面运行 DispatcherServlet/DispatcherPortlet:在这种情况下,使用 RequestContextListener 或 RequestContextFilter 暴露当前 要求。 线 |方法 ->> 96 |在 grails.plugins.quartz.GrailsJobFactory$GrailsJob 中执行 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 216 |在 org.quartz.core.JobRunShell 中运行 ^ 549 |跑步 。 .在 org.quartz.simpl.SimpleThreadPool$WorkerThread
由 IllegalStateException 引起:未找到线程绑定请求:您指的是 请求实际网络之外的属性 请求,或处理原始接收之外的请求 线?如果您实际上是在 Web 请求中操作并且仍然 收到此消息,您的代码可能在 DispatcherServlet/DispatcherPortlet:在这种情况下,使用 RequestContextListener 或 RequestContextFilter 暴露当前 要求。 ->> 131 | org.springframework.web.context.request.RequestContextHolder 中的 currentRequestAttributes"
这是我的代码:
def execute() {
pingService.checkPing()
}
def checkPing = {
User user = User.findByLogin(session.user.login) //get user
def hostsToPing = importFromDB()
if (!hostsToPing.isEmpty()) {
hostsToPing.each {host ->
doPing(host)
}
} else {
//something else
}
}
def importFromDB = {
User user = User.findByLogin(session.user.login)
def hostsList = Host.findAllByUser(user)
hostsList
}
def doPing(Host host) {
println "InetAdress: " + InetAddress.getByName(host.hostAdress)
println "InetAdress is Rea: " + InetAddress.getLocalHost().isReachable(1000)
}
当是这样的时候就不存在这个问题了:
def doPing(Host host) {
println "InetAdress: " + InetAddress.getByName("www.google.com")
println "InetAdress is Reachable : " + InetAddress.getLocalHost().isReachable(1000)
}
有谁知道怎么回事?
【问题讨论】: