首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

Spring调用Quartz定时任务报Couldn't store trigger错误

2013-09-11 
Spring调用Quartz定时任务报Couldnt store trigger异常Quartz定时任务配置如下:bean idjobDetail val

Spring调用Quartz定时任务报Couldn't store trigger异常
Quartz定时任务配置如下:

<bean id="jobDetail" value = "com.quartz.job.TestJob"/>          <property name="jobDataAsMap">              <map>                  <!-- 非spring管理的service放到这里,就可以注入进去 -->                  <description>jobDataAsMap</description>                  <!-- key 属性值,value 对应的bean -->                  <entry key="test" value="testjobDataAsMap" />              </map>          </property>      </bean>             <bean id="testTrigger" ref="jobDetail"/><property name="cronExpression" value="0 * * * * ?"/></bean><bean name="scheduler" ref="txManager"></property><property name="startupDelay" value="30"></property><property name="schedulerContextAsMap">  <map>  <!-- spring 管理的service需要放到这里,才能够注入成功 -->  <description>schedulerContextAsMap</description>  <entry key="key" value="value"/></map>  </property><property name="applicationContextSchedulerContextKey">  <value>applicationContext</value>  </property></bean>   


启动服务器报异常如下:

Injection of resource fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scheduler' defined in file [D:\J2EE\workspace\12-kdvp_new\webapps\WEB-INF\classes\config\applicationContext-quartz.xml]: Invocation of init method failed; nested exception is org.quartz.JobPersistenceException: Couldn't store trigger: org.springframework.web.context.support.XmlWebApplicationContext [See nested exception: java.io.NotSerializableException: org.springframework.web.context.support.XmlWebApplicationContext]at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessAfterInstantiation(CommonAnnotationBeanPostProcessor.java:292)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)at java.security.AccessController.doPrivileged(Native Method)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)at org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderServlet.java:81)at javax.servlet.GenericServlet.init(GenericServlet.java:212)at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1172)at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992)at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4371)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)at org.apache.catalina.core.StandardService.start(StandardService.java:516)at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)at org.apache.catalina.startup.Catalina.start(Catalina.java:578)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)



原因见:[url]https://jira.springsource.org/browse/SPR-2850 [/url]


quartz-all-1.6.0.jar中的一个bug,到时定时器不能正确持久化到数据库中。


解决办法更新quartz.jar。升级到1.6.2,jar包在附件中。
我的异常网推荐解决方案:org.springframework.beans.factory.BeanCreationException:,http://www.myexception.cn/j2ee/10759.html

热点排行