I am using Spring 1.1.3 and Quartz 1.4.5.
I've gotten into quite a pickle.
I run automated integration tests that, upon setup, create an empty database from scratch and populate it with some default data, and then upon teardown delete the database.
I have recently added persistent Quartz scheduling to the mix, and as part of the test setup I create the empty Quartz tables.
However, the database creation and setup happens AFTER the application context is loaded, (b/c the application context contains the DataSource information) but the org.springframework.scheduling.QuartzSchedulerFact oryBean tries to access the tables from within afterPropertiesSet(), which happens during application context creation, BEFORE I get a chance to create them! So I get this error:
org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Table 'db_test.qrtz_locks' doesn't exist [See nested exception: java.sql.SQLException: Table 'db_test.qrtz_locks' doesn't exist]]
The applicable lines from the stack trace:
at org.quartz.impl.StdSchedulerFactory.instantiate(St dSchedulerFactory.java:915)
at org.quartz.impl.StdSchedulerFactory.getScheduler(S tdSchedulerFactory.java:1047)
at org.springframework.scheduling.quartz.SchedulerFac toryBean.createScheduler(SchedulerFactoryBean.java :467)
at org.springframework.scheduling.quartz.SchedulerFac toryBean.afterPropertiesSet(SchedulerFactoryBean.j ava:419)
What I'd really like to do is be able to wire everything up before any JDBC calls are attempted, but the fact that they are embedded in afterPropertiesSet() seems to make that impossible.
Is my only option to create my own copy of the SchedulerFactoryBean that behaves the way I want? I started to go down that path but it started to get hairy and I'm wondering if I'm missing somethign simple.