0
我有我在正確的文件夾(我有一個電子郵件插件,它在一個控制器工作良好,IV測試它)Grails的呼叫服務錯誤
class SendMailService {
static transactional = false
def serviceMethod() {
sendMail {
to "xxx"
from "xxx"
subject "Hello Fred"
body 'How are you?'
}
}
}
服務,我稱它是石英插件內工作:
class SendAlertJob {
def timeout = 5000l // execute job once in 5 seconds
def execute() {
def SendMailService
SendMailService.serviceMethod()
}
}
,並收到此錯誤:
2011-12-12 20:37:59,781 [quartzScheduler_Worker-3] ERROR listeners.ExceptionPrinterJobListener - Exception occured in job: GRAILS_JOBS.tv_megazineplus.SendAlertJob
org.quartz.JobExecutionException: Cannot invoke method serviceMethod() on null object [See nested exception: java.lang.NullPointerException: Cannot invoke method serviceMethod() on null object]
at org.codehaus.groovy.grails.plugins.quartz.GrailsJobFactory$GrailsTaskClassJob.execute(GrailsJobFactory.java:81)
at org.quartz.core.JobRunShell.run(JobRunShell.java:199)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:546)
Caused by: java.lang.NullPointerException: Cannot invoke method serviceMethod() on null object
at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at tv_megazineplus.SendAlertJob.execute(SendAlertJob.groovy:11)
at sun.reflect.GeneratedMethodAccessor287.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:186)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:171)
at org.codehaus.groovy.grails.plugins.quartz.GrailsJobFactory$GrailsTaskClassJob.execute(GrailsJobFactory.java:77)
... 2 more
天哪,不能相信,如果修復。戈納試試。 – recoInrelax
這是正確的答案 – recoInrelax