当我关闭在Tomcat上运行的战争时,会收到以下错误消息:
[2012-05-03 11:55:36,082] ERROR - org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(501) | Destroy method on bean with name 'threadPoolTaskExecutor' threw an exception
java.lang.NoClassDefFoundError: org/springframework/orm/jpa/EntityManagerFactoryUtils
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessBeforeDestruction(PersistenceAnnotationBeanPostProcessor.java:357)
at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:193)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:498)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:474)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:442)
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1066)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1040)
at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:958)
Caused by: java.lang.ClassNotFoundException: org.springframework.orm.jpa.EntityManagerFactoryUtils
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
... 8 more
在我的pom.xml中,我具有spring-orm 3.1.1.RELEASE作为依赖项.更奇怪的是,我可以进入PersistenceAnnotationBeanPostProcessor类,该类是spring-orm 3.1.1.RELEASE类,但找不到位于同一jar中的EntityManagerFactoryUtils类.我猜测它一定与它是抽象的或静态的有关,但我不确定朝这个问题的进一步研究方向.似乎真的应该可以使用.
任何人都在想为什么会发生这种情况?
解决方法:
确实,这可能是我的排除问题(尝试调用mvndependency:tree来解决此问题).
战争中有罐子吗? Tomcat库中是否还有另一个Spring jar?这可能是类加载器问题.