使用Spring + quartz集群持久化时注意事项
2017-10-11 21:31
295 查看
1、持久化时未序列化异常
java.io.NotSerializableException: Unable to serialize JobDataMap for insertion into database because the value of property 'methodInvoker' is not
serializable: org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean
例如:
[html] view
plain copy
<bean id="studyDetail"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<ref bean="studyJob" />
</property>
<property name="targetMethod">
<value>doSth</value>
</property>
</bean>
原因请看org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean
[html] view
plain copy
NOTE: JobDetails created via this FactoryBean are not serializable and thus not suitable for persistent job stores. You need to implement your own Quartz Job as a thin wrapper for each case where you want a persistent job to delegate to a specific service method.
Compatible with Quartz 1.5+ as well as Quartz 2.0-2.2, as of Spring 3.2.
所以对于持久化的job需要自己继承org.springframework.scheduling.quartz.QuartzJobBean,同时修改JobDetailFactoryBean为
[html] view
plain copy
<bean id="studyDetail"
class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
<property name="jobClass">
<value>com.joshua.job.StudyJob</value>
</property>
<property name="name" value="studyDetail"></property>
<property name="durability" value="true" />
</bean>
2.持久化时jobDetail找不到
[java] view
plain copy
org.quartz.JobPersistenceException: The job (DEFAULT.studyDetail) referenced by the trigger does not exist.
原因一般是数据源配置导致的问题。
可能的原因是:数据源未配置成自动提交,当第一次启动trigger时,之前对数据库的job的增加的事物没有自动提交,导致后面的事物无法查询到。
如果数据源是通过dbcp配置的将自动提交配置为true
[html] view
plain copy
<property name="defaultAutoCommit" value="false" />
如果是c3p0配置为autoCommitOnClose=true
java.io.NotSerializableException: Unable to serialize JobDataMap for insertion into database because the value of property 'methodInvoker' is not
serializable: org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean
例如:
[html] view
plain copy
<bean id="studyDetail"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<ref bean="studyJob" />
</property>
<property name="targetMethod">
<value>doSth</value>
</property>
</bean>
原因请看org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean
[html] view
plain copy
NOTE: JobDetails created via this FactoryBean are not serializable and thus not suitable for persistent job stores. You need to implement your own Quartz Job as a thin wrapper for each case where you want a persistent job to delegate to a specific service method.
Compatible with Quartz 1.5+ as well as Quartz 2.0-2.2, as of Spring 3.2.
所以对于持久化的job需要自己继承org.springframework.scheduling.quartz.QuartzJobBean,同时修改JobDetailFactoryBean为
[html] view
plain copy
<bean id="studyDetail"
class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
<property name="jobClass">
<value>com.joshua.job.StudyJob</value>
</property>
<property name="name" value="studyDetail"></property>
<property name="durability" value="true" />
</bean>
2.持久化时jobDetail找不到
[java] view
plain copy
org.quartz.JobPersistenceException: The job (DEFAULT.studyDetail) referenced by the trigger does not exist.
原因一般是数据源配置导致的问题。
可能的原因是:数据源未配置成自动提交,当第一次启动trigger时,之前对数据库的job的增加的事物没有自动提交,导致后面的事物无法查询到。
如果数据源是通过dbcp配置的将自动提交配置为true
[html] view
plain copy
<property name="defaultAutoCommit" value="false" />
如果是c3p0配置为autoCommitOnClose=true
相关文章推荐
- 使用Spring + quartz集群持久化时注意事项
- redis 集群中 Slave-read-only 参数的使用注意事项
- Quartz使用注意事项
- Zookeeper集群使用注意事项
- 集群中使用session的注意事项
- Spring对Quartz的封装实现简单分析及使用注意事项
- java 使用quartz 定时xml 配置 与注解 以及注意事项
- css display:none使用注意事项小结
- union联合体使用注意事项
- 在T-SQL中使用临时表的注意事项
- SVN使用注意事项
- AudioRecord 使用小结与注意事项
- 数据泵使用的注意事项之远程导入导出
- MySQL索引类型总结和使用技巧以及注意事项
- struts使用的一些注意事项
- 使用org.apache.commons.logging打日志注意事项
- ORACLE分区表梳理系列(一)- 分区表概述、分类、使用方法及注意事项
- 内联函数使用注意事项
- AudioRecord 使用小结与注意事项
- ListView使用注意事项