如何解决HTTP状态500 - ContainerException java.lang.NoSuchMethodError错误

时间:2017-10-14 07:07:55

标签: java hibernate rest jpa tomcat8

如何解决HTTP状态500 -

  

org.glassfish.jersey.server.ContainerException:   java.lang.NoSuchMethodError:   org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava / UTIL /地图   异常?

我无法理解这个问题。 我正在使用Tomcat 8。

 <properties>
     <jersey.version>2.25.1</jersey.version>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
    <dependencies>
        <groupId>org.glassfish.jersey</groupId>
        <artifactId>jersey-bom</artifactId>
        <version>${jersey.version}</version>
        <type>pom</type>
    </dependency>
</dependencyManagement>

<dependencies>
    <dependency>
       <groupId>javax.ws.rs</groupId>
       <artifactId>javax.ws.rs-api</artifactId>
       <version>2.0.1</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet-core</artifactId> 
    </dependency>
    <dependency>
        <groupId>org.codehaus.jettison</groupId>
        <artifactId>jettison</artifactId>
        <version>1.3.8</version>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.2.8.Final</version>
    </dependency> 
    <dependency>
        <groupId>com.thetransactioncompany</groupId>
        <artifactId>cors-filter</artifactId>
        <version>2.2</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>6.0.5</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-moxy</artifactId>
    </dependency> 
    <dependency> 
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.moxy</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>javax.persistence</groupId>
        <artifactId>persistence-api</artifactId>
        <version>1.0.2</version>
    </dependency>...

Error

Hibernate class

1 个答案:

答案 0 :(得分:0)

1)尝试在lib目录中的某个位置查找servlet容器中的嵌入式hibernate库。它可能包含一些旧版本,并且与pom.xml

中指定的版本冲突

2)您使用的是基于JPA 2.x构建的最新版本的hibernate。您使用的版本1.0.2可能会导致一些冲突。尝试向最新的2.1 API添加依赖项并删除现有的API。例如:

<dependency>
    <groupId>org.hibernate.javax.persistence</groupId>
    <artifactId>hibernate-jpa-2.1-api</artifactId>
    <version>1.0.0.Final</version>
</dependency>