spring quartz 与自动装配 产生的问题
来源:互联网 发布:wps数据表格怎么做 编辑:程序博客网 时间:2024/05/01 16:39
<beans default-lazy-init="true" default-autowire="byName">
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false">
<property name="triggers">
<list><ref bean="clearLogsTrigger" /></list>
</property>
</bean>
...
</beans>
如果default-autowire="byName",则此时会产生如下错误:
Error creating bean with name 'org.springframework.scheduling.quartz.SchedulerFactoryBean#0' defined in file [E:/workspace/eis_oracle2/web/WEB-INF/classes/conf/spring/eisSystemScheduleContext.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
解决:自动装配惹得祸,存在dataSource这个bean就自动用数据库的状态维持了。故去掉default-autowire="byName"
原因:此时的quartz是jobstore用的HDBCJobStore模式,此时会从数据库查询任务。
quartz应该是使用数据进行job的状态的维护的,但是在数据库中没有找到相应的table,从而无法正常建立scheduler 。
即使是采取内存存储的模式,配置如下:
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false">
<property name="triggers">
<list> <ref bean="clearLogsTrigger" /></list>
</property>
<property name="quartzProperties">
<props>
<prop key="org.quartz.jobStore.class">org.quartz.simpl.RAMJobStore</prop>
</props>
</property>
</bean>
- if (this.dataSource != null) {
- mergedProps.put(StdSchedulerFactory.PROP_JOB_STORE_CLASS, LocalDataSourceJobStore.class.getName());
- }
SchedulerFactoryBean的setDataSource(DataSource)方法javadoc说:
Set the default DataSource to be used by the Scheduler. If set, this will override corresponding settings in Quartz properties.
Note: If this is set, the Quartz settings should not define a job store "dataSource" to avoid meaningless double configuration.
A Spring-specific subclass of Quartz' JobStoreCMT will be used. It is therefore strongly recommended to perform all operations on the Scheduler within Spring-managed (or plain JTA) transactions. Else, database locking will not properly work and might even break (e.g. if trying to obtain a lock on Oracle without a transaction).
Supports both transactional and non-transactional DataSource access. With a non-XA DataSource and local Spring transactions, a single DataSource argument is sufficient. In case of an XA DataSource and global JTA transactions, SchedulerFactoryBean's "nonTransactionalDataSource" property should be set, passing in a non-XA DataSource that will not participate in global transactions.
- spring quartz 与自动装配 产生的问题
- Spring依赖配置与自动装配的先后顺序问题
- Quartz SchedulerFactoryBean异常--Spring自动装配惹的祸
- Quartz SchedulerFactoryBean异常--Spring自动装配惹的祸
- Quartz SchedulerFactoryBean异常--Spring自动装配惹的祸
- 关于Spring的自动装配问题
- SPRING的自动装配
- spring的自动装配
- spring的自动装配
- Spring的自动装配
- spring的自动装配
- Spring的自动装配
- spring的自动装配
- spring的自动装配
- Spring的自动装配
- Spring 的自动装配
- spring的自动装配
- spring 的自动装配
- c
- continue的应用,类似goto
- 2009年锐捷网络工程师认证试题RCNA实验考试
- AJAX (XHR)异步请求的一些认识
- 100108 心理专家提示成熟人格需达到四条标准
- spring quartz 与自动装配 产生的问题
- 听面试官谈求职面试的十条技巧
- WIN7 的上帝模式
- VC++用OO4O连接Oracle数据库
- 善喻---沟通不应该那么苍白
- ubuntu安装oracle 10g
- 所谓幸福
- 数据库高手请进
- 新朋友来了