Home > Java > javaTutorial > Why Does My Play Framework App with Hibernate 4.3.0.Final Throw a NoSuchMethodError: javax.persistence.Table.indexes()?

Why Does My Play Framework App with Hibernate 4.3.0.Final Throw a NoSuchMethodError: javax.persistence.Table.indexes()?

DDD
Release: 2024-11-25 09:07:12
Original
863 people have browsed it

Why Does My Play Framework App with Hibernate 4.3.0.Final Throw a NoSuchMethodError: javax.persistence.Table.indexes()?

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"
)
Copy after login

Notes:

  • This solution is applicable to Play 2.2.x. Minor differences may exist in the build files for previous versions.
  • After making these changes, rebuilding the application should resolve the NoSuchMethodError exception.

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template