Java – error creating bean in quartz scheduler
•
Java
I changed the quartz library from version 1.5 2 is changed to 2.1 2. Using its old version, the project runs and works normally, but in 2.1 2 I got an 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
applicationContext. Quartz declaration in 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 the problem. Maybe I'll help you
Solution
Quartz 2 support has been added in spring version 3.1:
http://static.springsource.org/spring/docs/3.1.0.RC1/changelog.txt
Either update spring dependencies to this version (at least) or use quartz 1.8 Version x
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码