NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
Problem:
Upon upgrading from Hibernate 4.2.5 to 4.3.0, an exception has been raised:
NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
This issue persists with Hibernate versions 4.2.6-4.2.8, but not with 4.2.5.
Solution:
The issue arises due to a dependency conflict between Play Java JPA and Hibernate 4.3. Play Java JPA depends on the JPA 2.0 specification, while Hibernate 4.3 utilizes the newer JPA 2.1 specification.
Fix:
Modify the build.sbt file by adding the following dependency:
libraryDependencies ++= Seq( javaJdbc, javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"), "org.hibernate" % "hibernate-entitymanager" % "4.3.0.Final" )
This step excludes the JPA 2.0 dependency and ensures that only JPA 2.1 is used. This solution is applicable to Play 2.2.x versions.
Note:
The issue may require different modifications for earlier versions of Play.
The above is the detailed content of Why Does Upgrading Hibernate from 4.2.5 to 4.3.0 Cause a NoSuchMethodError for javax.persistence.Table.indexes()?. For more information, please follow other related articles on the PHP Chinese website!