2017-03-31 102 views
0

升级到4.2.5春天已经引起了各国的石英调度启动的问题 - 的NoSuchMethodError:org.quartz.Scheduler.getListenerManager期间()升级到4.2.5春天已经引起周围石英调度启动错误

遇到异常上下文初始化 - 取消刷新尝试:org.springframework.beans.factory.BeanCreationException:在文件[SaPvApp-context.xml]中定义的名为'intAppService'的bean创建时出错:设置bean属性'quartzScheduler时无法解析对bean'quartzScheduler'的引用“;创建嵌套的异常是org.springframework.beans.factory.Bean

CreationException:在文件[C:\ Integration Apps \ SAPV \ config \ SaPvApp-context.xml]中定义名称为'quartzScheduler'的Bean时创建错误: 调用init方法失败;嵌套异常是java.lang.NoSuchMethodError:org.quartz.Scheduler.getListenerManager()Lorg/quartz/ListenerManager;

从POM

<dependency> 
    <groupId>org.opensymphony.quartz</groupId> 
    <artifactId>quartz</artifactId> 
    <version>1.6.5</version> 
</dependency> 

从上下文文件:

<bean name="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> 
    <property name="autoStartup" value="false" /> 
    <property name="schedulerName" value="PvScheduler" /> 
    <property name="triggers"> 
     <list> 
      <!-- <ref bean="cronTrigger" /> --> 
     </list> 
    </property> 
</bean> 

<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> 
    <property name="targetObject" ref="serviceTask" /> 
    <property name="targetMethod" value="run" /> 
    <property name="concurrent" value="false" /> 
    <property name="group" value="PV" /> 
    <property name="name" value="${app.service.name}${app.service.instance}-Job" /> 
    <property name="jobListenerNames"> 
     <list> 
      <!-- <value>PvJobListener</value> --> 
     </list> 
    </property> 
</bean> 

<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> 
    <property name="jobDetail" ref="jobDetail" /> 
    <!--<property name="cronExpression" value="10 0/01 * * * ?" />--> 
    <!-- run twice a day at 3am and 3pm --> 
    <property name="cronExpression" value="0 0 3,15 ? * *" /> 
    <!-- run every 30 minutes, at 10 seconds after the minute (i.e. 10:00:10 am, 10:30:10 am, etc.) 
    <property name="cronExpression" value="10 0/30 * * * ?" /> --> 
</bean> 

编辑:尝试升级到石英2.2.2:

/** 
* Listen for Job and Scheduler events. 
*/ 
public void listen() { 
    if (this.quartzScheduler != null) { 
     try { 
      this.quartzScheduler.addJobListener(this); 
      this.quartzScheduler.addSchedulerListener(this); 
     } 
     catch (SchedulerException e) { 
      throw new IntegrationServiceException("listen", e); 
     } 
    } 
} 

错误:

的方法addJobListener(QuartzTas kScheduler)是未定义的类型调度

方法addSchedulerListener(QuartzTaskScheduler)是未定义的类型调度

编辑17年4月3日: 我能够通过添加抽象=” true以解决抽象错误”我的bean定义但是,我得到下面发布了一个新的错误:

Error creating bean with name 'jobDetail' defined in file [C:\Integration Apps\SAPV\config\SaPvApp-context.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'jobListenerNames' of bean class 

[org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean]: Bean property 'jobListenerNames' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1518) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) 
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) 
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) 
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753) 
     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) 
     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) 
     at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140) 
     at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84) 
     at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:93) 
     at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:54) 
     at cmd.SaPvApp.main(SaPvApp.java:18) 
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'jobListenerNames' of bean class [org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean]: Bean property 'jobListenerNames' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 
     at org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:231) 
     at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:423) 
     at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:280) 
     at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95) 
     at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1514) 
     ... 15 more 

编辑17年4月3日PT2: 我注释掉jobListernersNames,并得到了新的错误:

org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.scheduling.quartz.CronTriggerBean] for bean with name 'cronTrigger' defined in file [C:\Integration Apps\SAPV\config\SaPvApp-context.xml]; nested exception is java.lang.ClassNotFoundException: 

org.springframework.scheduling.quartz.CronTriggerBean 
     at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1352) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:628) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:597) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1445) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:975) 
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:752) 
     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) 
     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) 
     at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140) 
     at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84) 
     at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:93) 
     at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:54) 
     at cmd.SaPvApp.main(SaPvApp.java:18) 
Caused by: java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean 
     at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
     at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) 
     at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
     at org.springframework.util.ClassUtils.forName(ClassUtils.java:250) 
     at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:394) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1397) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1344) 
     ... 12 more 

这里是上下文的状态。xml文件(注意,如果我加回裁判cronTrigger它得到我最初的错误:

<bean name="intAppService" class="QuartzTaskScheduler" init-method="listen" abstract="true"> 
    <property name="name" value="PvJobListener" /> 
    <property name="quartzScheduler" ref="quartzScheduler"/> 
</bean> 

<bean name="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> 
    <property name="autoStartup" value="false" /> 
    <property name="schedulerName" value="PvScheduler" /> 
    <property name="triggers"> 
     <list> 
      <!--<ref bean="cronTrigger" />--> 
     </list> 
    </property> 
</bean> 

<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> 
    <property name="targetObject" ref="serviceTask" /> 
    <property name="targetMethod" value="run" /> 
    <property name="concurrent" value="false" /> 
    <property name="group" value="PV" /> 
    <property name="name" value="${app.service.name}${app.service.instance}-Job" /> 
    <!--<property name="jobListenerNames"> 
     <list> 
      <value>PvJobListener</value> 
     </list> 
    </property>--> 
</bean> 

<bean name="serviceTask" class="SaPvService"> 
    <property name="serviceTaskName" value="${app.service.name}${app.service.instance}"/> 
    <property name="hoursRepository" ref="hoursRepository"/> 
    <property name="primaveraSessionService" ref="primaveraSessionService"/> 
    <property name="resourceRateProcessor" ref="resourceRateProcessor"/> 
    <property name="workChunkRepository" ref="workChunkRepository"/> 
</bean> 

<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> 
    <property name="jobDetail" ref="jobDetail" /> 
    <!--<property name="cronExpression" value="10 0/01 * * * ?" />--> 
    <!-- run twice a day at 3am and 3pm --> 
    <property name="cronExpression" value="0 0 3,15 ? * *" /> 
    <!-- run every 30 minutes, at 10 seconds after the minute (i.e. 10:00:10 am, 10:30:10 am, etc.) 
    <property name="cronExpression" value="10 0/30 * * * ?" /> --> 
</bean> 

编辑17年4月3日PT2一个: 我把cronTrigger裁判回来了,这是这种情况的错误:

上下文:

<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> 
    <property name="jobDetail" ref="jobDetail" /> 
    <!--<property name="cronExpression" value="10 0/01 * * * ?" />--> 
    <!-- run twice a day at 3am and 3pm --> 
    <property name="cronExpression" value="0 0 3,15 ? * *" /> 
    <!-- run every 30 minutes, at 10 seconds after the minute (i.e. 10:00:10 am, 10:30:10 am, etc.) 
    <property name="cronExpression" value="10 0/30 * * * ?" /> --> 
</bean> 

<bean name="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> 
    <property name="autoStartup" value="false" /> 
    <property name="schedulerName" value="PvScheduler" /> 
    <property name="triggers"> 
     <list> 
      <ref bean="cronTrigger" /> 
     </list> 
    </property> 
</bean> 

错误:

2017-04-03 14:34:22,792 WARN {main} [org.springframework.context.support.FileSystemXmlApplicationContext] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.scheduling.quartz.CronTriggerBean] for bean with name 'cronTrigger' defined in file [C:\Integration Apps\SAPV\config\SaPvApp-context.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean 
*** SaPvApp: Unexpected service error at Mon Apr 03 14:34:23 CDT 2017 
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.scheduling.quartz.CronTriggerBean] for bean with name 'cronTrigger' defined in file [C:\Integration Apps\SAPV\config\SaPvApp-context.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean 
     at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1352) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:628) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:597) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1445) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:975) 
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:752) 
     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) 
     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) 
     at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140) 
     at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84) 
     at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:93) 
     at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:54) 
     at cmd.SaPvApp.main(SaPvApp.java:18) 
Caused by: java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean 
     at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
     at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) 
     at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
     at org.springframework.util.ClassUtils.forName(ClassUtils.java:250) 
     at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:394) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1397) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1344) 
     ... 12 more 

更新17年4月3日14 :55 CT: 我改变的背景文件CronTriggerBean现在CronTriggerFactoryBean 现在我收到此错误:

2017-04-03 14:52:47,570 INFO {main} [org.quartz.core.QuartzScheduler] - 

Scheduler meta-data: Quartz Scheduler (v2.2.2) 'PvScheduler' with instanceId 'NON_CLUSTERED' 
    Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally. 
    NOT STARTED. 
    Currently in standby mode. 
    Number of jobs executed: 0 
    Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads. 
    Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered. 

2017-04-03 14:52:47,572 INFO {main} [org.quartz.impl.StdSchedulerFactory] - Quartz scheduler 'PvScheduler' initialized from an externally provided properties instance. 
2017-04-03 14:52:47,574 INFO {main} [org.quartz.impl.StdSchedulerFactory] - Quartz scheduler version: 2.2.2 
2017-04-03 14:52:47,576 INFO {main} [org.quartz.core.QuartzScheduler] - JobFactory set to: [email protected]7c 
*** SaPvApp: Registering JVM shutdown hook 
*** SaPvApp: version 17.1.0 
*** SaPvApp: Adding service-stop event listeners 
*** SaPvApp: Starting service at Mon Apr 03 14:52:47 CDT 2017 
*** SaPvApp: Unexpected service error at Mon Apr 03 14:52:47 CDT 2017 
org.springframework.beans.factory.BeanIsAbstractException: Error creating bean with name 'intAppService': Bean definition is abstract 
     at org.springframework.beans.factory.support.AbstractBeanFactory.checkMergedBeanDefinition(AbstractBeanFactory.java:1288) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:285) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) 
     at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054) 
     at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:112) 
     at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:54) 
     at cmd.SaPvApp.main(SaPvApp.java:18) 
*** SaPvApp: Calling service stop event listeners 
*** SaPvApp: Exiting service at Mon Apr 03 14:52:47 CDT 2017 
*** SaPvApp ShutdownHook: Service shutdown initiated at Mon Apr 03 14:52:47 CDT 2017 
*** SaPvApp ShutdownHook: Closing application context 
2017-04-03 14:52:47,609 INFO {ApplicationShutdownHook} [org.springframework.context.support.FileSystemXmlApplicationContext] - Closing org.[email protected]63e31ee: startup date [Mon Apr 03 14:52:41 CDT 2017]; root of context hierarchy 
2017-04-03 14:52:47,615 INFO {ApplicationShutdownHook} [org.springframework.context.support.DefaultLifecycleProcessor] - Stopping beans in phase 2147483647 
2017-04-03 14:52:47,618 INFO {ApplicationShutdownHook} [org.springframework.scheduling.quartz.SchedulerFactoryBean] - Shutting down Quartz Scheduler 
2017-04-03 14:52:47,619 INFO {ApplicationShutdownHook} [org.quartz.core.QuartzScheduler] - Scheduler PvScheduler_$_NON_CLUSTERED shutting down. 
2017-04-03 14:52:47,620 INFO {ApplicationShutdownHook} [org.quartz.core.QuartzScheduler] - Scheduler PvScheduler_$_NON_CLUSTERED paused. 
2017-04-03 14:52:47,621 INFO {ApplicationShutdownHook} [org.quartz.core.QuartzScheduler] - Scheduler PvScheduler_$_NON_CLUSTERED shutdown complete. 
*** SaPvApp ShutdownHook: Service shutdown complete 

编辑17年4月4日07:59: 我试图创建一个父抽象类

<bean name="intAppServiceParent" abstract = "true"> 
    <property name="nameParent" value="PvJobListenerParent" /> 
    <property name="quartzSchedulerParent" ref="quartzSchedulerParent"/> 
</bean> 

<bean name="intAppService" class="QuartzTaskScheduler" init-method="listen" parent = "intAppServiceParent"> 
    <property name="name" value="PvJobListener" /> 
    <property name="quartzScheduler" ref="quartzScheduler"/> 
</bean> 

,但我得到这个错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'intAppService' defined in file [C:\Integration Apps\SAPV\config\SaPvApp-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [QuartzTaskScheduler]: Is it an abstract class?; nested exception is java.lang.InstantiationException 

如果我不作Java代码抽象类,我得到一个合作mpile错误一下:

The type QuartzTaskScheduler must implement the inherited abstract method SchedulerListener.triggersPaused(String) 

我不知道如何解决这个问题?

+0

看起来像春天4.2.5使用石英2.2.2:https://repo1.maven.org/maven2/org/springframework/spring-context-support/4.2.5.RELEASE/spring-context-support -4.2.5.RELEASE.pom你没有尝试升级它的版本吗? –

+0

如果我把ref和value放回去,我得到这个错误: property'triggers'with key [0];嵌套的异常是在文件[C:\ Integration Apps \ SAPV \ config \ SaPvApp-context.xml]中定义名称为'cronTrigger'的bean;嵌套异常是org.springframework.scheduling.quartz。CronTriggerBean – russell1997

+0

@RomanPuchkovskiy 我没有,但后来我得到的代码错误: 方法addJobListener(QuartzTaskScheduler)是未定义的类型调度 类型QuartzTaskScheduler必须实现继承的抽象方法SchedulerListener.jobAdded(JobDetail等) – russell1997

回答

0

我张贴散布在评论作为一个答案,使之更容易找到这些步骤的解决方案的步骤。

一些升级到4.2.5春天有石英集成所需的步骤:

  1. 春4.2.5使用石英2.2.2,不能用石英1.x的工作,所以石英版本必须是更新。
  2. addJobListener()addSchedulerListener()方法从QuartzScheduler移动到ListenerManager,这是通过getListenerManager()方法可用。除去
  3. setJobListenerNames()方法,所以jobListenerNames不应在XML配置进行设置。
+0

请问粘贴石英的依赖关系2.2.2。类似的问题,我面对..春季4.3.9和opernsymphony石英1.6.1 – spandey15

+0

@ spandey15 org.quartz调度 石英 2.2.2

0

你被覆盖的石英版本与温泉的版本兼容。从你的POM中取出石英版本声明或尝试石英版本升级到由Spring上下文4.2.5支持2.2.2。

+0

我做了升级石英,但然后我得到的代码错误,像这样的: 方法addJobListener(QuartzTaskScheduler)是未定义的类型调度 类型QuartzTaskScheduler必须实现继承的抽象方法SchedulerListener.jobAdded(JobDetail等) – russell1997

+0

方法addJobListener(QuartzTaskScheduler )是未定义的类型调度 方法addSchedulerListener(QuartzTaskScheduler)是未定义的类型调度 – russell1997

+0

公共无效听(){ \t \t如果(this.quartzScheduler!= NULL){ \t \t \t尝试{ \t \t \t \t this.quartzScheduler.addJobListener(this); \t \t \t \t this.quartzScheduler.addSchedulerListener(本); \t \t \t} \t \t \t赶上(SchedulerException E){ \t \t \t \t抛出新IntegrationServiceException( “听”,E); \t \t \t} \t \t} \t} – russell1997

0

除了升级弹簧和石英我需要专门修改Java代码周围QuartzTaskScheduler自升级代码没有实现所有的抽象方法。我必须全部实现它们。这可能是因为它的父类已经改变,加入太新抽象方法,或一些方法的签名被改变。