我正在使用Grails 3.3.11
和Quartz Grails插件2.0.13构建一个应用程序,有一些旧作业我将它们迁移到我的新应用程序,它们以前工作正常,但是现在我在尝试从Quartz监视器
页面手动运行它们时收到以下错误,在创建新作业并尝试手动运行它后也会收到相同的错误。知道可能导致此错误的原因以及如何解决它吗?
2020-09-07 17:12:29.308 ERROR --- [SchedulerThread] org.quartz.core.ErrorLogger : An error occured instantiating job to be executed. job= 'GRAILS_JOBS.utradeorders.EveryEndOfDayJob'
org.quartz.SchedulerException: Job instantiation failed
at org.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:45)
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 'utradeorders.EveryEndOfDayJob': Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.lang.Object]: Factory method 'newInstance' threw exception; nested exception is org.grails.core.exceptions.NewInstanceCreationException: Could not create a new instance of class [utradeorders.EveryEndOfDayJob]!
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.b
eans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1177)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1072)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:331)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1082)
at grails.plugins.quartz.GrailsJobFactory.createJobInstance(GrailsJobFactory.java:48)
at grails.plugins.quartz.QuartzMonitorJobFactory.super$3$createJobInstance(QuartzMonitorJobFactory.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1433)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:145)
at grails.plugins.quartz.QuartzMonitorJobFactory.createJobInstance(QuartzMonitorJobFactory.groovy:24)
at org.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:41)
... 2 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.lang.Object]: Factory method 'newInstance' threw exception; nested exception is org.grails.core.exceptions.NewInstanceCreationException: Could not create a new instance of class [utradeorders.EveryEndOfDayJob]!
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 22 common frames omitted
Caused by: org.grails.core.exceptions.NewInstanceCreationException: Could not create a new instance of class [utradeorders.EveryEndOfDayJob]!
at org.grails.core.AbstractGrailsClass.newInstance(AbstractGrailsClass.java:128)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1433)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 23 common frames omitted
Caused by: groovy.lang.MissingMethodException: No signature of method: static grails.web.api.WebAttributes.$init$() is applicable for argument types: (utradeorders.EveryEndOfDayJob) values: [utradeorders.EveryEndOfDayJob@27cf1bcc]
Possible solutions: wait(), find(), print(java.lang.Object), print(java.io.PrintWriter), println(), wait(long)
at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1518)
at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1504)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:921)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:181)
at grails.web.api.WebAttributes$Trait$Helper.$static_methodMissing(WebAttributes.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1433)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1516)
at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1504)
at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:52)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at utradeorders.EveryEndOfDayJob.<init>(EveryEndOfDayJob.groovy)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorNewInstance(ReflectiveInterceptor.java:1076)
at org.grails.core.AbstractGrailsClass.newInstance(AbstractGrailsClass.java:118)
... 29 common frames omitted
以下是我的工作示例:
class EveryEndOfDayJob {
//def utilsService
static triggers = {
cron name: "daily", cronExpression: "0 0 1 * * ?"
}
def execute() {
println("Job is running")
}
}
下载Grails 3.3.13并创建全新项目后,您可以添加插件石英2.0.13,一切按预期工作:https://github.com/majkelo/stackoverflow-quartz-issue
如果我是你,我会关注例外:
原因:org.springframework.beans.factory.BeanCreationException:创建名为“utradeorder”的bean时出错。AllEndOfDayJobs':通过工厂方法进行Bean实例化失败;嵌套异常org.springframework.beans.BeanInstantiationException:实例化[java.lang.对象]失败:工厂方法“newInstance”抛出异常;嵌套异常org.grails.core.exceptions.NewInstanceCreationException:无法创建类的新实例[utradeorder. AllEndOfDayJobs]!
特别是检查:创建名为“utradeorders”的bean时出错。EveryEndOfDayJob'
您是否将此作业放在正确的位置/子文件夹中?如果将其移出utradeorder
子文件夹会发生什么?
当我审查build.gradle
时,我发现它是编写的compile'org.grails.plugins: stone: 2.0.13'
我将其更改为runtime
,一切都按预期工作。