将事务性Grails服务注入Quartz插件作业将提供BeanCreationExecption

将事务性Grails服务注入Quartz插件作业将提供BeanCreationExecption,grails,grails-plugin,Grails,Grails Plugin,Grails版本:2.3.5 石英插件版本:1.0.2 我正在创建一个内部Grails插件。该插件依赖于Grails Quartz插件 我有一个Grails服务:OrchestratorJobExecutorService public class OrchestratorJobExecutorService { def grailsApplication def jobManagerService public void execute() { //d

Grails版本:2.3.5 石英插件版本:1.0.2

我正在创建一个内部Grails插件。该插件依赖于Grails Quartz插件

我有一个Grails服务:OrchestratorJobExecutorService

public class OrchestratorJobExecutorService {
    def grailsApplication
    def jobManagerService

    public void execute() {
        //do a bunch of stuff using here 
        //using grailsApplication to find a bunch of artifacts I've created in this plugin
        //using jobManagerService to check if trigger exists, then re/schedule job as needed
    }
}
我有一份石英的工作:OrchestratorJob

public class OrchestratorJob {
    def orchestratorJobExecutorService
    static triggers = {cron cronExpression: "0 0 15 * * ? *"}
    def group = "orchestrator"
    public execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        orchestratorJobExecutorService.execute()
    }
}
当这个作业执行时,我得到一个org.springframework.beans.factory.BeanCreationException

....core.ErrorLogger An error occured instantiating job to be executed. job= 'myPlugin.com.bgc.OrchestratorJob'
org.quartz.SchedulerException: Job instantiation failed [See nested exception: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.bgc.TamiOrchestratorJob': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myPluginOrchestratorJobExecutorService': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined]
    at org.quartz.core.JobRunShell.initialize(JobRunShell.java:127)
    at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:375)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.bgc.OrchestratorJob': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myPluginOrchestratorJobExecutorService': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined
    at grails.plugins.quartz.GrailsJobFactory.createJobInstance(GrailsJobFactory.java:48)
    ... 2 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myPluginOrchestratorJobExecutorService': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined
    ... 3 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined
    ... 3 more
我的plugingallsplugin.groovy文件中没有太多特殊的内容。除了基本插件版本/说明/文档行之外,我还更改了以下几行:

def loadAfter = ['controllers','services','spring-security-core','quartz','myOtherPlugin']
def pluginExcludes = [/*a bunch of folders with files I use to test and run my plugin*/]
我没有在doWith*闭包或on*闭包中定义任何其他内容

如果我将
static transactional=false
添加到OrchestratorJobExecutor服务中,错误就会消失。我有几个工作和服务,我必须检查我的整个插件,并将每个服务设置为非事务性的。我真的觉得不舒服,离开事务性服务让我感到害怕。在使用这个插件的主应用程序中,我创建的一些插件人工制品中会有大量的数据库交互

有人知道我如何保持我的服务是事务性的,并且仍然让它们被注入吗

====编辑2014年10月20日=====

添加了hibernate 3依赖项:

runtime ":hibernate:3.6.10.17"
新错误:

context.GrailsContextLoader Error initializing the application: org.springframework.beans.factory.annotation.InjectionMetadata.needsRefresh(Lorg/springframework/beans/factory/annotation/InjectionMetadata;Ljava/lang/Class;)Z
java.lang.NoSuchMethodError: org.springframework.beans.factory.annotation.InjectionMetadata.needsRefresh(Lorg/springframework/beans/factory/annotation/InjectionMetadata;Ljava/lang/Class;)Z
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)
Error |
Forked Grails VM exited with error
多次运行
clean all
refresh dependencies
似乎无法解决该错误(这是我遇到无法理解的错误时的标准过程)

BuildConfig.groovy

grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"

grails.release.scm.enabled = false

grails.project.repos.snapshotArtifactory.url = "https://<mySnapshotRepoUrl>"
grails.project.repos.releaseArtifactory.url = "http://<myReleaseRepoUrl>"
grails.project.repos.snapshotArtifactory.username = "<topSecretUsername>"
grails.project.repos.snapshotArtifactory.password = '<topSecretPassword>'

grails.project.fork.test = false
grails.project.fork = [
    run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
    war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
    console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]

grails.project.dependency.resolver = "maven"
grails.project.dependency.resolution = {
    inherits("global") {}

    log "warn"

    repositories {
        grailsCentral()
        mavenCentral()
        mavenRepo ("https://<mySnapshotRepoUrl>"){updatePolicy "always"}
    }

    dependencies {
        compile("org.hamcrest:hamcrest-all:1.3")
    }

    plugins {
        build ":release:3.0.1"
        build (":tomcat:7.0.50"){export=false}
        compile "com.<myCompany>.plugins:myOtherPlugin:0.1-SNAPSHOT"
        compile ":quartz:1.0.2"
        runtime ":hibernate:3.6.10.17"
    }
}
grails.project.class.dir=“target/classes”
grails.project.test.class.dir=“目标/测试类”
grails.project.test.reports.dir=“目标/测试报告”
grails.release.scm.enabled=false
grails.project.repos.snapshotArtifactory.url=“https://”
grails.project.repos.releaseArtifactory.url=“http://”
grails.project.repos.snapshotArtifactory.username=“”
grails.project.repos.snapshotArtifactory.password=''
grails.project.fork.test=false
grails.project.fork=[
run:[maxMemory:768,minMemory:64,debug:false,maxPerm:256,forkReserve:false],
war:[maxMemory:768,minMemory:64,debug:false,maxPerm:256,forkReserve:false],
控制台:[maxMemory:768,minMemory:64,debug:false,maxPerm:256]
]
grails.project.dependency.resolver=“maven”
grails.project.dependency.resolution={
继承(“全局”){}
日志“警告”
存储库{
grailsCentral()
mavenCentral()
mavenRepo(“https://”){updatePolicy“始终”}
}
依赖关系{
编译(“org.hamcrest:hamcrest all:1.3”)
}
插件{
构建“:版本:3.0.1”
构建(“:tomcat:7.0.50”){export=false}
编译“com..plugins:myOtherPlugin:0.1-SNAPSHOT”
编译“:石英:1.0.2”
运行时“:hibernate:3.6.10.17”
}
}

您是否安装了Hibernate插件或其他GORM插件?如果不是的话,我想你不会走这么远,但这就是
transactionManager
bean的来源。

Burt,我没有为这个插件安装hibernate。我没有任何域,对于我的插件,我不需要任何持久性,我同意Quartz只做内存存储。在我的插件将被使用的地方,它确实需要这种持久性,并将安装hibernate插件。既然你提到了它,我想我遇到了一些网站建议我安装Hibernate插件。我不记得结果了,但我会再试一次,看看会发生什么。我在这方面有点不知所措,所以我不知道该找什么。希望我能提供正确的信息来帮助解决这个问题。我添加了一个Hibernate3依赖项,并用结果编辑了文章。