【问题标题】:Could not parse - org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory无法解析 - org.dom4j.DocumentException:org.dom4j.DocumentFactory 无法转换为 org.dom4j.DocumentFactory
【发布时间】:2009-11-26 15:23:08
【问题描述】:

我正在将我的应用程序部署到 Tomcat 6.0.20。

应用程序使用 Hibernate 作为 Web 层的 ORM、Spring 和 JSF。

我还从 main() 方法制作了简单的 runner 来测试 Spring-Hibernate 协作。它确实工作正常,并且 hibernate.cfg.xml 被解析得很好。

我可以附加一些代码或完整的堆栈跟踪,但我不确定是否有必要,因为 Google 说这是典型问题,而且很容易从标题中识别出来。不幸的是,我找不到解决方案..

那么,谁知道如何解决这个问题?

【问题讨论】:

    标签: java hibernate tomcat


    【解决方案1】:

    确保您的类路径中没有两个不同的 dom4j jar。

    【讨论】:

    • 一个在tomcat系统类路径中,一个在你的webapp中。
    • @bmargulies:对。我们不得将休眠 jars 放入 Tomcat 中。一定要把它放在网络应用程序库中。
    【解决方案2】:

    我通过从休眠实体管理器中排除 dom4j 来解决它。

    还要确保你之前使用mvn clean

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.1.5.SP1</version>
            <scope>compile</scope>
            <exclusions> 
                <exclusion>
                    <groupId>dom4j</groupId>
                    <artifactId>dom4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    

    【讨论】:

      【解决方案3】:

      我通过将 dom4j 添加到我的pom.xml 并提供范围来解决

      <dependency>
          <groupId>dom4j</groupId>
          <artifactId>dom4j</artifactId>
          <version>1.6.1</version>
          <scope>provided</scope>
      </dependency>
      

      【讨论】:

      • 它也对我有用。我的配置是 spring 3.6.3.2.11.RELEASE Hibernate 3.6.10.Finaljboss-eap-4.3 中运行
      猜你喜欢
      • 2019-03-25
      • 1970-01-01
      • 2021-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-16
      • 1970-01-01
      相关资源
      最近更新 更多