2013-05-07 45 views
0

我正在使用带有Quartz插件1.0-RC7的Grails 2.2.2(GGTS-3.3.0M1)。在Grails石英插件中创建Job(factory-bean返回null)时出错

通过以下工作,我得到一个错误,指出在使用'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的创造在职',这下添加一个文件的grails-app /职位/ 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添加了“编译”:quartz:1.0-RC7“'依赖项。 我错过了什么?如果我定义了“组”,这并不重要,但我仍然会遇到错误。我看不到有关为什么bean创建返回null的更多错误。

回答

0

我想的作业容器的这一部分不...

高清grailsApplication < < < - 为什么你引用此,从来没有使用它吗? :)

另一个线程/博客或其他一些craptacular grails文档方法学有关于使用一个你的域对象来获得ctx,spring善良的句柄的提示。

def grailsApplication = new MyDomain().domainClass.grailsApplication 
def ctx = grailsApplication.mainContext