【问题标题】:Error creating Job (factory-bean returned null) in Grails quartz plugin在 Grails 石英插件中创建作业时出错(工厂 bean 返回 null)
【发布时间】:2013-12-11 03:48:51
【问题描述】:

我正在使用带有 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 的错误。

【问题讨论】:

    标签: quartz-scheduler grails-plugin grails-2.0


    【解决方案1】:

    我认为这不是工作容器的一部分...

    def grailsApplication

    另一个线程/博客或其他一些古怪的 grails 文档方法有这样的提示,即使用您的域对象来处理 ctx,spring goodness。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-08
      相关资源
      最近更新 更多