AHungerArtist
AHungerArtist

Reputation: 9609

Class not found even though it should be on the classpath

I get this error when I shutdown my war running on 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

In my pom.xml, I have spring-orm 3.1.1.RELEASE as a dependency. What's even more strange is that I can get into the PersistenceAnnotationBeanPostProcessor class which is a spring-orm 3.1.1.RELEASE class, yet it can't find the EntityManagerFactoryUtils class which is in the same jar. I'm guessing it must have something to do with it being abstract or static but I'm unsure in what further direction to investigate this issue. It really seems like it should be available.

Anyone have thoughts on why this might be happening?

Upvotes: 3

Views: 4739

Answers (2)

Miki
Miki

Reputation: 11

I solved the same issue by removing redundant dependency in one of my maven modules. I had direct dependency and indirect through some other module and that caused this behavior.

Upvotes: 1

Samuel EUSTACHI
Samuel EUSTACHI

Reputation: 3156

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.

Upvotes: 3

Related Questions