我正在使用Spring Framework在Oracle DB上实现Quartz Job Store。我的ApplicationContext.xml位于
之下<bean id="driverJob" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="BatchFileCollector" />
</bean>
<bean id="ranchTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail" ref="driverJob" />
<property name="startDelay" value="2000" />
<property name="repeatInterval" value="10000" />
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="ranchTrigger" />
</list>
</property>
<property name="dataSource">
<ref bean="dataSource.TEXAN"/>
</property>
<property name="applicationContextSchedulerContextKey">
<value>applicationContext</value>
</property>
<property name="autoStartup">
<value>true</value>
</property>
<property name="configLocation" value="classpath:quartz.properties"/>
</bean>
此配置给出了以下错误。
引起:org.quartz.JobPersistenceException:无法存储触发器:触发器引用的作业(DEFAULT.driverJob)不存在。 [请参阅嵌套异常:org.quartz.JobPersistenceException:触发器引用的作业(DEFAULT.driverJob)不存在。]
我正在使用Spring Framework 2.5.6。我是否必须升级我的Quartz版本? 我找不到问题。
感谢您的帮助。
答案 0 :(得分:13)
您的SchedulerFactoryBean也需要注册“driverJob”。与您的触发器一起,添加jobDetails列表。
<bean id="job.statistics.DailyQPSValidationJobTrigger" class="org.quartz.CronTrigger">
<property name="name" value="DailyQPSValidationTrigger" />
<property name="jobName" value="DailyQPSValidation" />
<property name="jobGroup" value="Statistics" />
<property name="volatility" value="false" />
<!-- Each day, 4 o'clock AM -->
<property name="cronExpression" value="0 0 4 * * ?" />
</bean>
<!-- Scheduler -->
<bean id="job.SchedulerProperties" class="somecompany.someproduct.util.spring.PropertiesFactoryBean"
scope="singleton">
<property name="source">
<props>
<prop key="org.quartz.scheduler.instanceId">AUTO</prop>
<prop key="org.quartz.scheduler.instanceName">JobCluster</prop>
<prop key="org.quartz.jobStore.class">org.quartz.impl.jdbcjobstore.JobStoreTX</prop>
<prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.StdJDBCDelegate</prop>
<prop key="org.quartz.jobStore.isClustered">true</prop>
<prop key="org.quartz.jobStore.useProperties">false</prop>
</props>
</property>
</bean>
<bean id="job.Scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" scope="singleton"
lazy-init="false">
<property name="startupDelay" value="30" />
<property name="waitForJobsToCompleteOnShutdown" value="true" />
<property name="dataSource" ref="jdbc.DataSource" />
<property name="quartzProperties" ref="job.SchedulerProperties" />
<property name="jobDetails">
<list>
<ref bean="job.statistics.DailyQPSValidationJobDetail" />
</list>
</property>
<property name="triggers">
<list>
<ref bean="job.statistics.DailyQPSValidationJobTrigger" />
</list>
</property>
<property name="schedulerListeners">
<list>
<bean class="somecompany.someproduct.job.SchedulerErrorListener">
<property name="monitoringService" ref="monitoring.MonitoringService" />
</bean>
</list>
</property>
<property name="globalJobListeners">
<list>
<bean class="somecompany.someproduct.job.JobErrorListener">
<property name="name" value="JobErrorListener" />
<property name="monitoringService" ref="monitoring.MonitoringService" />
</bean>
</list>
</property>
</bean>
答案 1 :(得分:2)
我对Quartz 1.5.2和Spring 3.0.4也有同样的问题。问题是JobStoreSupport类尝试将带有外键的cron触发器存储到作业中(尝试从db加载作业),该操作尚未保留。
与石英1.6.1,1.7.2版本相同的问题。
<bean id="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"
depends-on="quartzDatabaseCreator">
<property name="autoStartup">
<value>true</value>
</property>
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="quartzProperties">
<props>
<prop key="org.quartz.jobStore.selectWithLockSQL">SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?
</prop>
<prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.${qrtz.delegateClass}
</prop>
</props>
</property>
<property name="triggers">
<list>
<ref bean="cronTrigger"/>
</list>
</property>
<property name="schedulerContextAsMap">
<map>
<entry key="sygnoServerHelper"><ref bean="sygnoServerHelper"/></entry>
<entry key="requestDAO"><ref bean="requestDAO"/></entry>
<entry key="alairoCache"><ref bean="alairoCache"/></entry>
</map>
</property>
</bean>
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="checkGracePeriodJob" />
<!-- # s m h dom mon dow [y] -->
<property name="cronExpression" value="0 0/5 * * * ?" />
</bean>
<bean id="checkGracePeriodJob" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.synergon.sygnoserver.CheckGracePeriodJob"/>
</bean>
答案 2 :(得分:0)
我不确定这是否有效,但您可以尝试使用:
<bean id="driverJob" .../>
而不是:
<bean name="driverJob" .../>