HISPACTA Hell

Thursday, January 29, 2009

Quartz Scheduler Not Working? Don't forget lazy-init=false

I followed the line-by-line instructions in the Spring 2.5.x documentation on integrating Quartz with Spring and couldn't, for the life of me, get the Quartz jobs to run.

Long story short, try throwing in a lazy-init="false" in your configuration for the SchedulerFactoryBean.

Here's my configurations for a automatically re-loading a bunch of XML files off a file system every 120 seconds:


<bean id="abstractDAORefreshTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean" abstract="true">

<!-- Delay 10 seconds before starting -->
<property name="startDelay" value="10000">

<!-- Then run every 120 seconds thereafter -->
<property name="repeatInterval" value="120000">
</bean>

<bean id="tipCacheRefreshTrigger" parent="abstractDAORefreshTrigger">
<property name="jobDetail" ref="tipCacheRefreshJobDetail"> </bean>

<!-- A list of Triggers to be scheduled and executed by Quartz -->
<bean lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="autoStartup" value="true">
<property name="triggers">
<list>
<ref bean="tipCacheRefreshTrigger">
</list>
</property>
</bean>
<bean id="tipCacheRefreshJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="tipCache">
<property name="targetMethod" value="refresh">
<!-- Don't run 2 of these jobs at the same time! -->
<property name="concurrent" value="false">
</bean>