Hi everyone!!!
I write an app in Grails but I have some problems with quartz.
I wanna fetch User from DB and after that fetch his servers as well.
If there will be any server I wanna check PING command on each one, but I get a message like this:
"
[quartzScheduler_Worker-1] ERROR listeners.ExceptionPrinterJobListener - Exception occurred in job: GRAILS_JOBS.<name>
Message: 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.
Line | Method
->> 96 | execute in grails.plugins.quartz.GrailsJobFactory$GrailsJob
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 216 | run in org.quartz.core.JobRunShell
^ 549 | run . . in org.quartz.simpl.SimpleThreadPool$WorkerThread
Caused by 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.
->> 131 | currentRequestAttributes in org.springframework.web.context.request.RequestCon textHolder"
This is my code.
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)
}
There isn't this problem when is something like this:
def doPing(Host host) {
println "InetAdress: " + InetAddress.getByName("www.google.com")
println "InetAdress is Reachable : " + InetAddress.getLocalHost().isReachable(1000)
}
Does anyone know whats wrong?
Thanks,
Kacu
I write an app in Grails but I have some problems with quartz.
I wanna fetch User from DB and after that fetch his servers as well.
If there will be any server I wanna check PING command on each one, but I get a message like this:
"
[quartzScheduler_Worker-1] ERROR listeners.ExceptionPrinterJobListener - Exception occurred in job: GRAILS_JOBS.<name>
Message: 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.
Line | Method
->> 96 | execute in grails.plugins.quartz.GrailsJobFactory$GrailsJob
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 216 | run in org.quartz.core.JobRunShell
^ 549 | run . . in org.quartz.simpl.SimpleThreadPool$WorkerThread
Caused by 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.
->> 131 | currentRequestAttributes in org.springframework.web.context.request.RequestCon textHolder"
This is my code.
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)
}
There isn't this problem when is something like this:
def doPing(Host host) {
println "InetAdress: " + InetAddress.getByName("www.google.com")
println "InetAdress is Reachable : " + InetAddress.getLocalHost().isReachable(1000)
}
Does anyone know whats wrong?
Thanks,
Kacu