How can I resolve java.lang.ClassNotFoundException: org.hibernate.util.DTDEntityResolver when using Spring 3.1 with Hibernate 4.0.1?

前端 未结 5 1055
太阳男子
太阳男子 2021-01-03 18:14

I recently upgraded to Hibernate 4.0.1.Final and am receiving the following error on context startup:

Caused by: jav         


        
相关标签:
5条回答
  • 2021-01-03 18:49

    I had faced same issue, after removing dependencies for hibernate annotation, I was able to run my code successfully.

    0 讨论(0)
  • 2021-01-03 18:50

    Per the Hibernate annotations 3.5 documentation:*

    Hibernate 3.5 and onward contains Hibernate Annotations.

    You should remove the dependency on hibernate-annotations, and remove the excludes from the hibernate-entitymanager dependency. Generally, you should not mix versions of dependent packages.

    * and JB Nizet's comment.

    0 讨论(0)
  • 2021-01-03 18:57

    Add this dependency to your pom.xml

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>tck-utils-api</artifactId>
        <version>0.9.1</version>
    </dependency>
    
    0 讨论(0)
  • 2021-01-03 18:58

    I had same problem now it's fine with my these dependencies.

    <properties>
        <spring.version>4.0.5.RELEASE</spring.version>
        <junit.version>4.11</junit.version>
        <jdk.version>1.6</jdk.version>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    
        <!-- Spring dependencies -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
    
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
    
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
    
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
        </dependency>
    
        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>3.0-alpha-1</version>
        </dependency>
    
        <!-- JSTL -->
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
    
    
        <!-- Apache Commons Upload -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.2.2</version>
        </dependency>
    
        <!-- Apache Commons Upload -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.3.2</version>
        </dependency>
    
        <!-- MYSQL dependency -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
        </dependency>
    
        <!-- Hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.3.5.Final</version>
        </dependency>
    
        <!-- If using JPA (2), add: -->
    
    
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.5.6</version>
        </dependency>
    
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.6</version>
        </dependency>
    
        <dependency>
            <groupId>c3p0</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.1.2</version>
        </dependency>
    
        <dependency>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.18.1-GA</version>
        </dependency>
    
    </dependencies>
    
    0 讨论(0)
  • 2021-01-03 19:03

    This may not be the case for this issue, but I had a similar dependency error on 'hibernate envers', after I removed it the program started working.

    <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-envers</artifactId>
            <version>LATEST</version>
        </dependency>`
    
    
       
    
    0 讨论(0)
提交回复
热议问题