运行后发现如下异常:
严重 : Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException : Error creating bean with name 'cronTriggerPunch' defined in ServletContext resource [/WEB-INF/applicationContext-attend.xml]: Cannot create inner bean 'org.springframework.scheduling.quartz.JobDetailBean#15e92d7' of type [org.springframework.scheduling.quartz.JobDetailBean] while setting bean property 'jobDetail'; nested exception is org.springframework.beans.factory.BeanCreationException : Error creating bean with name 'org.springframework.scheduling.quartz.JobDetailBean#15e92d7' defined in ServletContext resource [/WEB-INF/applicationContext-attend.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException : Could not instantiate bean class [org.springframework.scheduling.quartz.JobDetailBean]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.commons.collections.SetUtils.orderedSet(Ljava/util/Set;)Ljava/util/Set;
Caused by: org.springframework.beans.factory.BeanCreationException : Error creating bean with name 'org.springframework.scheduling.quartz.JobDetailBean#15e92d7' defined in ServletContext resource [/WEB-INF/applicationContext-attend.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException : Could not instantiate bean class [org.springframework.scheduling.quartz.JobDetailBean]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.commons.collections.SetUtils.orderedSet(Ljava/util/Set;)Ljava/util/Set;
Caused by: org.springframework.beans.BeanInstantiationException : Could not instantiate bean class [org.springframework.scheduling.quartz.JobDetailBean]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.commons.collections.SetUtils.orderedSet(Ljava/util/Set;)Ljava/util/Set;
Caused by: java.lang.NoSuchMethodError: org.apache.commons.collections.SetUtils.orderedSet(Ljava/util/Set;)Ljava/util/Set;
at org.quartz.JobDetail.
at org.springframework.scheduling.quartz.JobDetailBean.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0( Native Method )
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.springframework.beans.BeanUtils.instantiateClass( BeanUtils.java:85 )
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate( SimpleInstantiationStrategy.java:61 )
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean( AbstractAutowireCapableBeanFactory.java:757 )
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance( AbstractAutowireCapableBeanFactory.java:722 )
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean( AbstractAutowireCapableBeanFactory.java:386 )
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean( BeanDefinitionValueResolver.java:216 )
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary( BeanDefinitionValueResolver.java:123 )
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues( AbstractAutowireCapableBeanFactory.java:1100 )
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean( AbstractAutowireCapableBeanFactory.java:862 )
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean( AbstractAutowireCapableBeanFactory.java:423 )
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject( AbstractBeanFactory.java:249 )
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton( DefaultSingletonBeanRegistry.java:155 )
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean( AbstractBeanFactory.java:246 )
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean( AbstractBeanFactory.java:160 )
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons( DefaultListableBeanFactory.java:291 )
at org.springframework.context.support.AbstractApplicationContext.refresh( AbstractApplicationContext.java:352 )
at org.springframework.web.context.ContextLoader.createWebApplicationContext( ContextLoader.java:246 )
at org.springframework.web.context.ContextLoader.initWebApplicationContext( ContextLoader.java:189 )
at org.springframework.web.context.ContextLoaderListener.contextInitialized( ContextLoaderListener.java:49 )
at org.apache.catalina.core.StandardContext.listenerStart( StandardContext.java:3843 )
at org.apache.catalina.core.StandardContext.start( StandardContext.java:4342 )
at org.apache.catalina.core.ContainerBase.addChildInternal( ContainerBase.java:791 )
at org.apache.catalina.core.ContainerBase.addChild( ContainerBase.java:771 )
at org.apache.catalina.core.StandardHost.addChild( StandardHost.java:525 )
at org.apache.catalina.startup.HostConfig.deployDirectory( HostConfig.java:926 )
at org.apache.catalina.startup.HostConfig.deployDirectories( HostConfig.java:889 )
at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:492 )
at org.apache.catalina.startup.HostConfig.start( HostConfig.java:1149 )
at org.apache.catalina.startup.HostConfig.lifecycleEvent( HostConfig.java:311 )
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent( LifecycleSupport.java:117 )
at org.apache.catalina.core.ContainerBase.start( ContainerBase.java:1053 )
at org.apache.catalina.core.StandardHost.start( StandardHost.java:719 )
at org.apache.catalina.core.ContainerBase.start( ContainerBase.java:1045 )
at org.apache.catalina.core.StandardEngine.start( StandardEngine.java:443 )
at org.apache.catalina.core.StandardService.start( StandardService.java:516 )
at org.apache.catalina.core.StandardServer.start( StandardServer.java:710 )
at org.apache.catalina.startup.Catalina.start( Catalina.java:578 )
at sun.reflect.NativeMethodAccessorImpl.invoke0( Native Method )
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start( Bootstrap.java:288 )
at org.apache.catalina.startup.Bootstrap.main( Bootstrap.java:413 )
在检查配置文件和代码都正确后,可能就是导入的jar包出现问题,一般情况下是你的commons-collections的版本太低了,于是当我把
commons-collections-3.2.jar 换成 commons-collections.jar 后这些异常全部消失了。
网上还有这种说法,是jar包冲突,检查WEB-INF/lib/ 下有cglib-2.1.3.jar和cglib-nodep-2.1_3.jar 应该去除前者,没验证过,但是还是希望这对遇到同样错误的学者有帮助。