6

I have an application using Spring 3.0.5, JPA2 and Hibernate 3.6.7. Maven's handling my dependency management. Here's a pom excerpt:

<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 builds just fine, however, when trying to load it, the Tomcat container 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:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

Any thoughts on what could be causing this? All the dependencies appear to be intact.

Thanks.

eugene
  • 956
  • 1
  • 11
  • 13

3 Answers3

6

You are mixing artifacts from Spring 2.x and 3.x.

Replace old 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> 
axtavt
  • 239,438
  • 41
  • 511
  • 482
  • thanks for pointing that out - removing the reference to spring-hibernate3 appears to clear things up – eugene Nov 09 '11 at 04:58
0

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

Kode Charlie
  • 1,297
  • 16
  • 32
0

I had exactly the same problem. I was hibernate validator (4.2), tomcat 6 and spring 3.0.6. But I also upgraded hibernate from 3.2 to 3.6, but I forgot to remove the hibernate-entitymanager.jar (which is an old hibernate jar) from the classpath.

dvtoever
  • 3,896
  • 1
  • 28
  • 29