问题描述
配置文件 <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"default-lazy-init="false"><!-- 要调用的工作类 --><bean id="job1" class="mainTest.Test1"></bean><!-- 定义调用对象和调用对象的方法 --><bean id="jobDetail_1"class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"><!-- 调用的类 --><property name="targetObject"><ref bean="job1" /></property><!-- 调用类中的方法 --><property name="targetMethod"><value>work</value></property></bean><!-- 定义触发时间 --><bean id="doTime" class="org.springframework.scheduling.quartz.CronTriggerBean"><property name="jobDetail"><ref bean="jobDetail_1" /></property><!-- cron表达式 --><property name="cronExpression"><!-- 每隔10秒执行一次 --><value>0/10 * * * * ?</value></property></bean><!-- 总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序 --><bean id="startQuertz" lazy-init="false" autowire="no"class="org.springframework.scheduling.quartz.SchedulerFactoryBean"><property name="triggers"><list><ref bean="doTime" /></list></property></bean></beans> 报错内容2011-11-21 18:01:48 org.springframework.web.context.ContextLoader initWebApplicationContextSEVERE: Context initialization failedorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobDetail_1' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.InstantiationError: org.quartz.JobDetailat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1403)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545)at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)at java.util.concurrent.FutureTask.run(FutureTask.java:166)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)at java.lang.Thread.run(Thread.java:732)Caused by: java.lang.InstantiationError: org.quartz.JobDetailat org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean.afterPropertiesSet(MethodInvokingJobDetailFactoryBean.java:177)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1400)... 20 more2011-11-21 18:01:48 org.apache.catalina.core.StandardContext listenerStartSEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobDetail_1' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.InstantiationError: org.quartz.JobDetailat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1403)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545)at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)at java.util.concurrent.FutureTask.run(FutureTask.java:166)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)at java.lang.Thread.run(Thread.java:732)Caused by: java.lang.InstantiationError: org.quartz.JobDetailat org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean.afterPropertiesSet(MethodInvokingJobDetailFactoryBean.java:177)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1400)... 20 more2011-11-21 18:01:48 org.apache.catalina.core.StandardContext startInternalSEVERE: Error listenerStart2011-11-21 18:01:48 org.apache.catalina.core.StandardContext startInternalSEVERE: Context [/quartz] startup failed due to previous errors2011-11-21 18:01:48 org.apache.catalina.core.ApplicationContext logINFO: Closing Spring root WebApplicationContext2011-11-21 18:01:48 org.apache.coyote.AbstractProtocolHandler startINFO: Starting ProtocolHandler ["http-bio-8080"]2011-11-21 18:01:48 org.apache.coyote.AbstractProtocolHandler startINFO: Starting ProtocolHandler ["ajp-bio-8009"]2011-11-21 18:01:48 org.apache.catalina.startup.Catalina startINFO: Server startup in 1014 ms 问题补充:asyty 写道
解决方案
你木有发现是同一位嚒 =。= 换1.8.5的啥版本的jar包试试
解决方案二:
Spring3.x还不支持quartz 2 所以把jar包换成1.X版本
解决方案三:
引用nested exception is java.lang.InstantiationError: org.quartz.JobDetail 你用的是quartz 2.X版本吧,在1.X版本里,org.quartz.JobDetail是一个类,但是在2.x里已经改成了interface,所以不能直接这样了。。。