NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index; in Hibernate
While using the Play Framework application with Hibernate 4.3.0.Final, users may encounter a NoSuchMethodError exception in javax.persistence.Table.indexes(). This issue is specific to Hibernate 4.3.0.Final and does not occur in previous versions like 4.2.5.Final.
Root Cause
The error occurs because of a conflict between different versions of the Hibernate specification in the application's classpath. The play-java-jpa artifact relies on Hibernate 2.0 API (hibernate-jpa-2.0-api), whereas Hibernate 4.3.0.Final introduces Hibernate 2.1 API. As a result, both API versions coexist within the classpath, leading to the NoSuchMethodError exception.
Solution
To resolve this issue, exclude the Hibernate 2.0 API dependency from the build.sbt file while including Hibernate 4.3.0.Final. Here's an updated version of the build.sbt file:
libraryDependencies ++= Seq( javaJdbc, javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"), "org.hibernate" % "hibernate-entitymanager" % "4.3.0.Final" )
Notes:
The above is the detailed content of Why Does My Play Framework App with Hibernate 4.3.0.Final Throw a NoSuchMethodError: javax.persistence.Table.indexes()?. For more information, please follow other related articles on the PHP Chinese website!