How to solve AbstractMethodError in Hibernate 5?

后端 未结 1 1962
南旧
南旧 2021-01-13 11:28

i\'m trying to use the hibernate 5 in Java EE with tomcat 7, and i\'m getting this error:

java.lang.AbstractMethodError
org.hibernate.internal.SessionFactory         


        
相关标签:
1条回答
  • 2021-01-13 12:21

    AbstractMethodError is thrown when you have incompatibility between the jar you used to compile and the one referred while server is running the code.

    http://docs.oracle.com/javase/7/docs/api/java/lang/AbstractMethodError.html

    "Thrown when an application tries to call an abstract method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled.

    It could be due to the versions of hibernate-search & hibernate-entity-manager

    hibernate search seems to be using hibernate-commons-annotations 4.0.5 final

    http://mvnrepository.com/artifact/org.hibernate/hibernate-search-engine/5.3.0.Final

    Whereas

    Hibernate entity manager seems to be using hibernate-commons-annotation-5.0.0.Final

    http://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager/5.0.1.Final

    Check your Dependency Hierarchy tab for pom.xml in eclipse to find out which exact jar version is being used. Use to exclude incompatible versions. usually this is done automatically by pom. You could also check your WEB-INF/lib folder to see what are jars are being downloaded.

    Also I see that you are using this jar. If you are using tomcat 7 better to use this instead and have its scope "provided" because at runtime the web app refers to the tomcat servlet api jar.

    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-servlet-api</artifactId>
        <version>7.0.21</version>
        <scope>provided</scope>
        </dependency>
    
    0 讨论(0)
提交回复
热议问题