Hi, I just put together a simple job using the quartz scheduler. The bean config XML file is as follows -
<bean id="schedulerFactory" class="org.springframework.scheduling.quartz.Sched ulerFactoryBean">
<property name="quartzProperties">
<props>
<prop key="org.quartz.scheduler.instanceName">GTPersiste ntScheduler</prop>
<prop key="org.quartz.scheduler.instanceId">GTS_STANDALO NE</prop>
<prop key="org.quartz.scheduler.rmi.export">false</prop>
<prop key="org.quartz.scheduler.rmi.proxy">false</prop>
<prop key="org.quartz.scheduler.userTransactionURL">java x.transaction.UserTransaction</prop>
<prop key="org.quartz.threadPool.class">org.quartz.simpl .SimpleThreadPool</prop>
<prop key="org.quartz.threadPool.threadCount">3</prop>
<prop key="org.quartz.threadPool.threadPriority">4</prop>
<prop key="org.quartz.jobStore.class">org.quartz.impl.jd bcjobstore.JobStoreTX</prop>
<prop key="org.quartz.jobStore.driverDelegateClass">org. quartz.impl.jdbcjobstore.WebLogicDelegate</prop>
<prop key="org.quartz.jobStore.dataSource">WeblogicDS</prop>
<prop key="org.quartz.jobStore.tablePrefix">QRTZ_</prop>
<prop key="org.quartz.jobStore.misfireThreshold">60000</prop>
<prop key="org.quartz.dataSource.WeblogicDS.jndiURL">jdb c/GeoTradesTxDS</prop>
<prop key="org.quartz.dataSource.WeblogicDS.jndiAlwaysLo okup">false</prop>
<prop key="org.quartz.dataSource.WeblogicDS.java.naming. factory.initial">weblogic.jndi.WLInitialContextFac tory</prop>
<prop key="org.quartz.dataSource.WeblogicDS.java.naming. provider.url">t3://erezdev:7007</prop>
<prop key="org.quartz.plugin.shutdownHook.class">org.qua rtz.plugins.management.ShutdownHookPlugin</prop>
<prop key="org.quartz.plugin.shutdownHook.cleanShutdown" >true</prop>
</props>
</property>
<property name="triggers">
<list>
<ref bean="cronMaintenanceTrigger"/>
</list>
</property>
</bean>
<bean id="maintenanceJob" class="org.springframework.scheduling.quartz.JobDe tailBean">
<property name="jobClass">
<value>com.itp.gt.scheduler.job.DailyExecutionClea nupJob</value>
</property>
<property name="jobDataAsMap">
<map>
<entry key="condition">
<value>DeleteExecutions</value>
</entry>
<entry key="jdbcTemplate">
<ref bean="jdbcTemplate"/>
</entry>
</map>
</property>
</bean>
<bean id="cronMaintenanceTrigger" class="org.springframework.scheduling.quartz.CronT riggerBean">
<property name="jobDetail">
<ref bean="maintenanceJob"/>
</property>
<property name="cronExpression">
<value>0/20 * * * * ?</value>
</property>
</bean>
I have two setters for each property in the scheduled job class - DailyExecutionCleanupJob. The problem is that only the 'condition' property is being set and the 'jdbcTemplate' turns out to be null.
The 'jdbcTemplate' is being used as a dataSource for initialization for a few other classes and it works fine. I suspect this has to do with the way the properties are set for a scheduled Job i.e. using the JobDataAsMap property and specifying the 'jdbcTemplate' as an entry property.
Can anyone help shed some light on this? Thanks.


Reply With Quote