Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not parse - org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory

I am deploying my application to Tomcat 6.0.20.

Application uses Hibernate as ORM, Spring, and JSF for web-tier.

I also made simple runner from main() method to test Spring-Hibernate collaboration. And it does work fine and hibernate.cfg.xml is parsed pretty well.

I can append some code or full stack trace but I'm not sure that it's necessary because Google says that it's typical problem and it's easy to recognize it from the title. Unfortunately, I couldn't find the solution..

So, who knows how to fix this problem?

like image 330
Roman Avatar asked Nov 26 '09 15:11

Roman


2 Answers

Make sure you don't have two different dom4j jars on your classpath.

like image 133
Bozho Avatar answered Sep 21 '22 09:09

Bozho


I solved it by excluding dom4j from hibernate entitymanager.

Also make sure you do mvn clean before.

    <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>
like image 23
Jaanus Avatar answered Sep 20 '22 09:09

Jaanus