由Spring Quartz 实例化时抛出SQL Exception的问题来看spring的autowire(自动装配)
项目使用Spring Quartz,声明如下schedule:
<beans default-autowire="byName">...<bean id="schedulerBackend" name="code">[ERROR][2010-03-02 15:06:25,549] Context initialization failedorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'backEndService' defined in class path resource [service-appContext.xml]: Cannot resolve reference to bean 'schedulerBackend' while setting bean property 'scheduler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'schedulerBackend' defined in class path resource [service-appContext.xml]: Invocation of init method failed; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: ORA-00942: table or view does not exist [See nested exception: java.sql.SQLException: ORA-00942: table or view does not exist]]at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1210)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:978)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:462)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:404)at java.security.AccessController.doPrivileged(Native Method)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:375)... ...Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'schedulerBackend' defined in class path resource [service-appContext.xml]: Invocation of init method failed; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: ORA-00942: table or view does not exist [See nested exception: java.sql.SQLException: ORA-00942: table or view does not exist]]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1302)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:463)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:404)at java.security.AccessController.doPrivileged(Native Method)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:375)... 35 moreCaused by: org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: ORA-00942: table or view does not exist [See nested exception: java.sql.SQLException: ORA-00942: table or view does not exist]]at org.quartz.impl.jdbcjobstore.JobStoreSupport.initialize(JobStoreSupport.java:493)at org.quartz.impl.jdbcjobstore.JobStoreCMT.initialize(JobStoreCMT.java:144)... 45 more
org.springframework.scheduling.quartz.SchedulerFactoryBean if(dataSource != null)mergedProps.put("org.quartz.jobStore.class", (org.springframework.scheduling.quartz.LocalDataSourceJobStore.class).getName());
<beans default-autowire="byName">...<bean id="schedulerBackend" name="code"><beans default-autowire="byName">...<bean id="schedulerBackend" autowire-candidate="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="schedulerName"><value>quartz_backend</value></property> <property name="triggers"><list><!-- 自定义Cron trigger bean --><ref local="Customer_CronTriggerBean"/> </list> </property></bean></beans>