java.lang.ang.NoClassDefFoundError:org / hibernate / util / DTDEntityResolver

时间:2013-01-04 09:56:16

标签: java spring hibernate struts2

我在部署我的maven build struts2-spring-hibernate web应用程序时遇到此错误。是否有人知道需要哪些maven依赖项来解决下面的问题?

11:52:00.479 [main] ERROR o.s.web.context.ContextLoader - Context initialization
 failed
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'sampleSessionFactory' defined in ServletContext resource [/WEB-INF/appli
cationContext.xml]: Invocation of init method failed; nested exception is java.l
ang.NoClassDefFoundError: org/hibernate/util/DTDEntityResolver
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455) ~[spring-be
ans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) ~[spring-beans
-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:456) ~[spring-beans-3
.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:294) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEAS
E]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:225) ~[spring-beans-3.1.1.RELEA
SE.jar:3.1.1.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:291) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:193) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:567) ~[spring-beans-3.1
.1.RELEASE.jar:3.1.1.RELEASE]

我目前正在使用下面提到的依赖项,但仍然会收到错误。

<dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.0.1.Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.0.1.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-tools</artifactId>
            <version>4.0.0-CR1</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>jtidy</artifactId>
            <version>r8-20060801</version>
        </dependency>

        <dependency>
            <groupId>org.beanshell</groupId>
            <artifactId>bsh</artifactId>
            <version>2.0b5</version>
        </dependency>
        <dependency>
            <groupId>freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.9</version>
        </dependency>

3 个答案:

答案 0 :(得分:0)

尝试回滚到休眠3,看来你正在寻找的类不包含在Hibernate 4库中。有些东西依赖于Hibernate 3。

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate</artifactId>
        <version>3.2.7.ga</version>
    </dependency>

After doing some further research, I learned that it is JTidy that has the dependency on Hibernate 3

答案 1 :(得分:0)

我编译'org.hibernate:hibernate-core:4.1.9'

我将它替换为编译'org.hibernate:hibernate-core:3.3.2.GA'

在我的build.gradle中

这是gradle语法,转换为maven并不困难,这解决了问题

答案 2 :(得分:0)

你作为依赖项添加的工件hibernate-tools版本4.0.0-CR1使用了hibernate-commons-annotations 3.2.0-Final,它使用了DTDEntityResolver。 您必须更改4.3.1.CR1的hibernate-tools版本(注意点,而不是破折号,在C之前),它使用hibernate-commons-annotations 4.0.4.Final,然后你'我不再有这个错误了。