【发布时间】:2011-01-18 06:31:55
【问题描述】:
我正在开发一个后端 Grails 应用程序,该应用程序定期从 RESTful 服务中提取信息。为此,我安装了 Grails Quartz 插件。
grails install-plugin quartz
然后我使用
创建了一个工作grails create-job My
它生成了一个我用 cron 触发器配置的 MyJob 文件
static triggers = {
cron name: 'myTrigger', cronExpression: '0 0 * * * ?' // hourly
}
在开发环境中本地运行应用程序可以正常工作,但是一旦我尝试构建测试或生产战争,当触发器运行时,我会收到以下异常。
2010-02-18, 00:04:32 ERROR org.codehaus.groovy.grails.web.context.GrailsContextLoader - Error occurred shutting down plug-in manager: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'quartzScheduler':
Cannot resolve reference to bean 'sessionBinderListener' while setting bean property 'jobListeners' with key [0]; nested
exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionBinderListener': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException : Access is denied: Session is closed
由于我不需要数据库,所以我尝试删除 Hibernate 插件as suggested, 但是一旦删除了 Hibernate 插件,我就会遇到编译问题:
Running script C:\Downloads\grails-1.2.1\scripts\RunApp.groovy
Environment set to development
[groovyc] Compiling 18 source files to C:\Projects\myapp\target\classes
[groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Compile error during compilation with javac.
[groovyc] ...\myapp\plugins\quartz-0.4.1\src\java\org\codehaus\groovy\grails\plugins\quartz\listeners\SessionBinderJobListener.java:19: package org.hibernate does not exist
[groovyc] import org.hibernate.FlushMode;
...
有没有办法在没有 Hibernate 插件的情况下使用 Quartz 插件?
如果没有,最好的办法是配置一个内存数据库供 Quartz 使用吗?(我不关心这些数据的持久性。)
【问题讨论】:
标签: hibernate grails plugins groovy quartz-scheduler