我有一个使用Grails开发的Web应用程序。我正在尝试实现一个后台进程,该进程使用Grails的quutz1.0-RC9插件每5分钟扫描一次DB中的表。
在尝试编写实际逻辑之前,我正在学习如何使用这个插件,因为我是石英的新手。所以我创建了一个作业,每5秒打印一次带有当前时间戳的消息“hai”。
class checkJob {
static triggers = {
simple name:'sampleQuartz', startDelay:10000, repeatInterval: 5000l, repeatCount: -1 // execute job once in 5 seconds
}
def execute() {
println "hai!!!"+new Date()// execute job
}
}
还有我的QuartzConfig。groovy是
quartz {
autoStartup = true
jdbcStore = false
waitForJobsToCompleteOnShutdown = true
exposeSchedulerInRepository = false
props {
scheduler.skipUpdateCheck = true
}
}
environments {
test {
quartz {
autoStartup = true
}
}
production {
quartz {
autoStartup = true
}
}
}
当使用命令grails run-app
运行时,这可以正常工作。但是当使用命令grails prod war
创建战争并且部署在Tomcat中时,什么都不起作用。即使index.html页面没有加载,它也会出现Http-404错误。
我在BuilConfig中引用了这个插件。groovy,如插件类别下的文档中所述。
compile ":quartz:1.0-RC9"
但什么都不管用。
然后我创建了一个新的Grails项目,它除了上面提到的quartz代码之外什么都没有,并使用Grails prod war
创建了一个war。这对Tomcat很管用。
我在用
Tomcat 6
Grails 2.0.1
石英1.0-RC9
在已经存在的grails应用程序中创建作业时我错过了什么?
请有人帮帮我。
我在这个问题上做了一些基础工作。通过grails dev war
创建我的grails应用程序“Timeprocess”的war并在Tomcat6下部署,我在localhost中获得了以下信息。txt文件
Jul 29, 2013 3:35:27 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Jul 29, 2013 3:35:32 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: Unable to locate constructor with Class parameter for class grails.plugins.quartz.DefaultGrailsJobClass
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:384)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.codehaus.groovy.grails.web.context.GrailsContextLoader.initWebApplicationContext(GrailsContextLoader.java:66)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.RuntimeException: Unable to locate constructor with Class parameter for class grails.plugins.quartz.DefaultGrailsJobClass
at org.codehaus.groovy.grails.commons.ArtefactHandlerAdapter.newArtefactClass(ArtefactHandlerAdapter.java:113)
at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.addArtefact(DefaultGrailsApplication.java:894)
at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.addArtefact(DefaultGrailsApplication.java:615)
at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.configureLoadedClasses(DefaultGrailsApplication.java:326)
at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.initialise(DefaultGrailsApplication.java:825)
at org.codehaus.groovy.grails.plugins.GrailsPluginManagerFactoryBean.afterPropertiesSet(GrailsPluginManagerFactoryBean.java:110)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 37 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.codehaus.groovy.grails.commons.ArtefactHandlerAdapter.newArtefactClass(ArtefactHandlerAdapter.java:104)
... 44 more
Caused by: java.lang.IncompatibleClassChangeError: Implementing class
at grails.plugins.quartz.config.TriggersConfigBuilder.createTrigger(TriggersConfigBuilder.groovy:74)
at grails.plugins.quartz.config.TriggersConfigBuilder.createNode(TriggersConfigBuilder.groovy:215)
at grails.plugins.quartz.config.TriggersConfigBuilder.createNode(TriggersConfigBuilder.groovy:208)
at Timeprocess.ScheduleScanJob$__clinit__closure1.doCall(ScheduleScanJob.groovy:7)
at grails.plugins.quartz.config.TriggersConfigBuilder.build(TriggersConfigBuilder.groovy:52)
at grails.plugins.quartz.DefaultGrailsJobClass.evaluateTriggers(DefaultGrailsJobClass.java:58)
at grails.plugins.quartz.DefaultGrailsJobClass.<init>(DefaultGrailsJobClass.java:48)
Jul 29, 2013 3:35:34 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jul 29, 2013 3:35:34 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jul 29, 2013 3:36:31 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Jul 29, 2013 3:36:31 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
谁能帮我指出这里出了什么问题吗?
我建议做一个:
grails clean
以及删除。slcache文件夹,您可以在
~/.grails/.slcache
问候