SpringPersistenceUnitInfo :: AbstractMethodError

I have an application using Spring 3.0.5, JPA2 and Hibernate 3.6.7. Maven handles my dependency management. Here is an excerpt from pom:

<properties> <spring.version>3.0.5.RELEASE</spring.version> </properties> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> ... <dependency> <groupId>org.springframework</groupId> <artifactId>spring-hibernate3</artifactId> <version>2.0.8</version> <scope>compile</scope> <exclusions> <exclusion> <groupId>org.hibernate</groupId> <artifactId>hibernate</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>3.6.7.Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>3.6.7.Final</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jpa</artifactId> <version>2.0.8</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.hibernate.java-persistence</groupId> <artifactId>jpa-api</artifactId> <version>2.0-cr-1</version> <scope>compile</scope> </dependency> ... 

The application just works fine, but when you try to download its container, Tomcat complains about the following:

  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed;  nested exception is java.lang.AbstractMethodError: org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo.getValidationMode () Ljavax / persistence / ValidationMode;
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean (AbstractAutowireCapableBeanFactory.java:1420)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.javaβˆ—19)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:456)

Any thoughts on what could be causing this? All dependencies look intact.

Thanks.

+6
source share
3 answers

You mix artifacts from Spring 2.x and 3.x.

Replace older versions of spring-hibernate3 and spring-jpa with

 <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${spring.version}</version> <scope>compile</scope> </dependency> 
+6
source

I had exactly the same problem. I was a sleep mode validator (4.2), tomcat 6, and spring 3.0.6. But I also updated hibernate from 3.2 to 3.6, but I forgot to remove hibernate-entitymanager.jar (which is the old sleeping jar) from the class path.

0
source

I had a very similar problem with Hibernate 4.x, Spring 3.x, JPA 2.x and CXF 2.7.5. I removed the link for the spring-jpa artifact in my POM maven file and inserted your recommended snippet. The magic worked! I no longer see an exception. Thanks!

0
source

Source: https://habr.com/ru/post/900918/


All Articles