Denees
Denees

Reputation: 9198

Error creating bean in Quartz-Scheduler

I changed the quartz library from version 1.5.2 to 2.1.2. With older version of it the project runs and works fine, but with 2.1.2 I get the exception:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lcJobDetail' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.InstantiationError: org.quartz.JobDetail
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1412)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:546)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.deveto.struts.triggers.TriggerTables.<clinit>(TriggerTables.java:36)
... 113 more
Caused by: java.lang.InstantiationError: org.quartz.JobDetail
at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean.afterPropertiesSet(MethodInvokingJobDetailFactoryBean.java:177)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
... 125 more

The quartz declaration from applicationContext.xml:

<bean name="lcTask" class="com.deveto.struts.triggers.TriggerLeagueCup"></bean>

<bean id="lcJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    <property name="targetObject" ref="lcTask" />
    <property name="targetMethod" value="execute" />
</bean>

<bean id="lcCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="lcJobDetail" />
    <property name="cronExpression" value="0 30 12 1/1 * ? *"/>
</bean>

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="triggers">
        <list>
           <ref bean="lcCronTrigger"/>
        </list>
    </property>
</bean>

I can't find where the problem is, maybe with your help guys I will.

Upvotes: 3

Views: 18038

Answers (1)

Shivan Dragon
Shivan Dragon

Reputation: 15219

Quartz2 support have been added in Spring version 3.1:

http://static.springsource.org/spring/docs/3.1.0.RC1/changelog.txt

either update your Spring dependencies to that version (atleast) or use Quartz version 1.8.x

Upvotes: 7

Related Questions