0

One of our apps is upgrading Spring from 2.5.6 to 4.2.5 and quartz 1.6.5 to 2.2.2. I have been working to resolve issues one by one but i'm down to this one that I can't seem to work out.

The error is:

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

here is my spring context file:

<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>

edit 4/4/17 07:59: I tried creating a parent abstract class

    <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>

but I'm getting this error:

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

If I don't make the java code class abstract I get a compile error about this:

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

I'm not sure how to fix this?

4

1 回答 1

0

问题在于 QuartzTaskScheduler,因为升级代码并没有实现所有抽象方法。我必须全部实施。可能是因为它的父类发生了变化,所以增加了新的抽象方法,或者一些方法的签名被改变了。

于 2017-04-04T13:54:52.163 回答