spring 3.2 和 quartz 2.1.7 集成

今天,做集成job。按着以前的步骤。心想应该直接可以运行吧,一运行。直接报错。

Caused by: java.lang.IncompatibleClassChangeError: class org.springframework.scheduling.quartz.JobDetailBean has interface org.quartz.JobDetail as super class

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)

at java.lang.ClassLoader.defineClass(ClassLoader.java:615)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)

at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1850)

at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:890)

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1354)

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)

at org.springframework.util.ClassUtils.forName(ClassUtils.java:260)

at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:416)

at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1290)

at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1261)

看了一下代码,发现JobDetail 变成接口了。在网上一搜发现用JobDetailFactoryBean类代替JobDetailBean类。

只好换了这个类。再次运行,还是抛出异常。异常如下: 

Caused by: java.lang.IncompatibleClassChangeError: class org.springframework.scheduling.quartz.CronTriggerBean has interface org.quartz.CronTrigger as super class

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)

at java.lang.ClassLoader.defineClass(ClassLoader.java:615)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)

at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1850)

at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:890)

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1354)

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)

at org.springframework.util.ClassUtils.forName(ClassUtils.java:260)

at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:416)

at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1290)

at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1261)

看了一下代码,发现CronTrigger  变成接口了。在网上一搜发现用CronTriggerFactoryBean类 代替CronTriggerBean 类。

只好换了这个类。 再次运行还是抛出异常。

Caused by: org.quartz.SchedulerException: Jobs added with no trigger must be durable.

at org.quartz.core.QuartzScheduler.addJob(QuartzScheduler.java:916)

at org.quartz.impl.StdScheduler.addJob(StdScheduler.java:269)

at org.springframework.scheduling.quartz.SchedulerAccessor.addJobToScheduler(SchedulerAccessor.java:342)

at org.springframework.scheduling.quartz.SchedulerAccessor.addTriggerToScheduler(SchedulerAccessor.java:365)

at org.springframework.scheduling.quartz.SchedulerAccessor.registerJobsAndTriggers(SchedulerAccessor.java:303)

at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet(SchedulerFactoryBean.java:511)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1547)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1485)

... 36 more

发现还需要在 org.springframework.scheduling.quartz.JobDetailFactoryBean bean中设置<property name="durability" value="true"></property> ,再次运行。终于成功了。

 

你可能感兴趣的:(Spring 3)