Java quartz和spring升级在抽象类/bean方面存在问题
我们的一个应用程序正在将Spring从2.5.6升级到4.2.5,并将quartz 1.6.5升级到2.2.2。 我一直在努力一个接一个地解决问题,但我最终还是解决不了这个问题 错误是:Java quartz和spring升级在抽象类/bean方面存在问题,java,spring,maven,quartz,Java,Spring,Maven,Quartz,我们的一个应用程序正在将Spring从2.5.6升级到4.2.5,并将quartz 1.6.5升级到2.2.2。 我一直在努力一个接一个地解决问题,但我最终还是解决不了这个问题 错误是: 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_CL
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: org.springframework.scheduling.quartz.AdaptableJobFactory@749ad37c
*** 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.springframework.context.support.FileSystemXmlApplicationContext@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
这是我的spring上下文文件:
<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 id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<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>
如果我不将java代码类抽象化,则会出现以下编译错误:
The type QuartzTaskScheduler must implement the inherited abstract method SchedulerListener.triggersPaused(String)
我不知道如何解决这个问题?问题出在QuartzTaskScheduler上,因为代码的升级没有实现所有的抽象方法。我必须全部实施。这可能是因为它的父类已更改,所以添加了新的抽象方法,或者某些方法的签名已更改。您在哪里定义了PvScheduler属性?@fabfas它在quartzScheduler bean中。@fabfas您是说bean也应该是抽象的吗?您在某处引用了
IntapService
(或者可能是由于init
方法)…bean被标记为abstract
,由于无法创建这样的实例,您只能将此定义用作其他bean的parent
。@M.Deinum我更新了OP。我尝试创建了抽象的父bean,然后在主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
The type QuartzTaskScheduler must implement the inherited abstract method SchedulerListener.triggersPaused(String)