Quartz2.2.1+spring4.0.6出现的异常

WARNING: Unable to load class [org.springframework.scheduling.quartz.JobDetailBean] to check against the @HandlesTypes annotation of one or more ServletContentInitializers. 
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.defineClass(ClassLoader.java:791)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2820)
	at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1150)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
	at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2006)
	at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:1969)
	at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1858)
	at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1826)
	at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1812)
	at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1306)
	at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:896)
	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:322)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5103)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
	at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3854)
	at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:424)
	at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1214)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1400)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1410)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1410)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1389)
	at java.lang.Thread.run(Thread.java:722)


我的配置文件:




       
       	
    		
    		 
        
		 
  			
 			
   				startJob
  			
 		
 		
		
			
			
		
		
		
		 
         
             
                 
             
        
       
 	




今天在公司整合Quartz和spring的时候,出现了以上的问题,找原因找不到,网上有说是版本问题,但是我看了spring3.X版本不能整合Quartz2.x版本的,只能和1.x的搭配使用,而我的是spring4.0.6+Quartz2.2.1,应该不会有不兼容的问题,于是根据错误提示开始看源码,

在org.springframework.scheduling.quartz.JobDetailBean中发下以下注释,

NOTE: This convenience subclass does not work against Quartz 2.0.
 * Use Quartz 2.0's native {@code JobDetailImpl} class or the new Quartz 2.0
 * builder API instead. Alternatively, switch to Spring's {@link JobDetailFactoryBean}
 * which largely is a drop-in replacement for this class and its properties and
 * consistently works against Quartz 1.x as well as Quartz 2.x.

我看了一下配置文件,又看了一下 org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean的源码,也确实是用的JobDetailImpl类

public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethodInvoker
		implements FactoryBean, BeanNameAware, BeanClassLoaderAware, BeanFactoryAware, InitializingBean {

	private static Class jobDetailImplClass;

	private static Method setResultMethod;

	static {
		try {
			jobDetailImplClass = ClassUtils.forName("org.quartz.impl.JobDetailImpl",
					MethodInvokingJobDetailFactoryBean.class.getClassLoader());
		}
		catch (ClassNotFoundException ex) {
			jobDetailImplClass = null;
		}
……

应该可以的啊,于是就去看了Quartz2.0的bug report (https://jira.spring.io/browse/SPR-8581)

发现如下:



Quartz2.2.1+spring4.0.6出现的异常_第1张图片


有人说是tomcat版本的问题,我看了一下自己的是tomcat7.0.22的,于是换了tomcat7.0.54的


成功类了~~~~果然是tomcat的版本的问题!!






你可能感兴趣的:(SSH)