3

当我关闭在 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 作为依赖项。更奇怪的是,我可以进入作为 spring-orm 3.1.1.RELEASE 类的 PersistenceAnnotationBeanPostProcessor 类,但它找不到在同一个 jar 中的 EntityManagerFactoryUtils 类。我猜它一定与它是抽象的或静态的有关,但我不确定进一步研究这个问题的方向。看起来它真的应该可用。

有人对为什么会发生这种情况有想法吗?

4

2 回答 2

3

Indeed, it might me an exclusion issue (try to call mvn dependency:tree to sort this out).

Do you have the jar in your war ? Do you have another Spring jar in Tomcat libs ? This could be a classloader issue.

于 2012-05-04T08:44:11.760 回答
0

我通过删除我的一个 Maven 模块中的冗余依赖项解决了同样的问题。我通过其他一些模块直接依赖和间接依赖,这导致了这种行为。

于 2015-01-30T08:25:11.710 回答