NoSuchMethodError in javax.persistence.Table.indexes()
In Play Framework applications using Hibernate, upgrading to Hibernate 4.3.0.Final can cause a NoSuchMethodError exception in javax.persistence.Table.indexes(). Here's why this occurs and how to resolve it:
Cause:
The issue arises due to a conflict between different versions of the JPA specifications loaded into the classpath. Play relies on a specific version of the JPA specification, while Hibernate 4.3.0.Final requires a newer version. When both versions are present, a conflict occurs, leading to the error.
Resolution:
To resolve this error, you need to exclude the older JPA specification from Play's classpath while adding the newer version required by Hibernate 4.3.0.Final.
For Play 2.2.x, modify your build.sbt file as follows:
libraryDependencies ++= Seq( javaJdbc, javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"), "org.hibernate" % "hibernate-entitymanager" % "4.3.0.Final" )
For earlier versions of Play, refer to the specific documentation for your version.
By excluding the older JPA specification, you ensure that only the newer version required by Hibernate 4.3.0.Final is used, resolving the conflict and the NoSuchMethodError exception.
The above is the detailed content of Why Does Upgrading to Hibernate 4.3.0.Final Cause a NoSuchMethodError in javax.persistence.Table.indexes()?. For more information, please follow other related articles on the PHP Chinese website!