Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring 3 + Quartz 2 error

Tags:

I received the error below when I use Spring 3 with Quartz 2. Does anyone knows the reason?

Error:

Exception in thread "main" org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.scheduling.quartz.JobDetailBean] for bean with name 'job' defined in class path resource [beans.xml]: problem with class file or dependent class; nested exception is java.lang.IncompatibleClassChangeError: class org.springframework.scheduling.quartz.JobDetailBean has interface org.quartz.JobDetail as super class     at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1253) 

Spring config file:

<bean name="job" class="org.springframework.scheduling.quartz.JobDetailBean">   <property name="jobClass" value="Example.ExampleJob"/>   <property name="jobDataAsMap">     <map>       <entry key="timeout" value="5"/>     </map>   </property> </bean>  <bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">   <property name="jobDetail" ref="job"/>   <property name="startDelay" value="1000"/>   <property name="repeatInterval" value="5000"/> </bean>  public class ExampleJob extends QuartzJobBean {        private int timeout;        /**        * Setter called after the ExampleJob is instantiated        * with the value from the JobDetailBean (5)        */        public void setTimeout(int timeout) {         this.timeout = timeout;       }      @Override     protected void executeInternal(JobExecutionContext ctx)             throws JobExecutionException {         *****     }  } 
like image 901
user705414 Avatar asked Nov 23 '11 15:11

user705414


1 Answers

If you use Spring 3.1,

Replace the SimpleTriggerBean with SimpleTriggerFactoryBean

In the 3.1 release, Spring has created Factory classes for crontrigger and simpletrigger

Update:

Using Spring 3.2.2, must be useful to change also JobDetailBean => JobDetailFactoryBean and CronTriggerBean => CronTriggerFactoryBean.

Credit to Osy (vote on the comment below)

like image 169
Fuping Avatar answered Dec 13 '22 05:12

Fuping