我正在使用带有 Quartz 插件 1.0-RC7 的 Grails 2.2.2 (GGTS - 3.3.0M1)。
对于以下作业,我收到一条错误消息,指出使用“grails run-app”进行测试时作业实例化失败。如果我从控制器显式调用 triggerNow() ,我会看到相同的错误。错误如下:
| Error 2013-05-07 10:50:20,260 [quartzScheduler_QuartzSchedulerThread] ERROR core.ErrorLogger - An error occured instantiating job to be executed. job= 'GRAILS_JOBS.mypkg.auth.OAuthJob'
Message: Job instantiation failed
Line | Method
->> 134 | initialize in org.quartz.core.JobRunShell
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
^ 387 | run in org.quartz.core.QuartzSchedulerThread
Caused by BeanCreationException: Error creating bean with name 'mypkg.auth.OAuthJob': factory-bean 'mypkg.auth.OAuthJobClass' returned null
我使用“grails create-job”命令创建了作业,该命令在 grails-app/jobs/mypkg/auth/OAuthJob.groovy 下添加了一个文件
package mypkg.auth
import org.quartz.JobExecutionContext
import org.quartz.JobExecutionException
//import org.grails.plugins.quartz.JobManagerService
class OAuthJob {
def AuthService
def grailsApplication
static triggers = {
// Execute job once in 11 hours (42600 seconds)
simple name = "OAuthTokenTrigger", repeatInterval: 426000000l
}
def group = "OAuthJobGroup"
def execute(JobExecutionContext context) throws JobExecutionException {
try {
log.debug("OAuthJob has been invoked, now requesting token")
// Call AuthService get token
AuthService.getToken(context.mergedJobDataMap)
} catch (Throwable e) {
throw new JobExecutionException(e.getMessage(), e)
}
}
}
我在 BuildConfig.groovy 中添加了一个 'compile":quartz:1.0-RC7"' 依赖项。我错过了什么?我是否定义了“组”并不重要,但我还是会收到错误消息。我没有看到任何关于为什么 bean 创建返回 null 的错误。