ClassCastException while parsing XML with WebLogic

2019-02-06 11:48发布

I'm getting the following error message:

java.lang.ClassCastException: weblogic.xml.jaxp.RegistryDocumentBuilderFactory cannot be cast to javax.xml.parsers.DocumentBuilderFactory

I've gone through some forums researching this. They said to remove xml-apis.jar or that JAR files were conflicting. But even though I did all the suggested steps, I'm getting the same error.

7条回答
\"骚年 ilove
2楼-- · 2019-02-06 12:26

I wanted make a slight addition to the previous answers to this question, in the event that anyone else is in the same situation I was. I had the same problem on our WebLogic 9.2 server due to my use of CXF 2.2.3. In addition to the removal of the xml-apis.jar mentioned previously, I also had to remove a xmlParserAPIs library.

As I am using Maven2 it was just a simple matter of adding another inclusion.

    <!-- CXF -->
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-bundle</artifactId>
        <version>${dependency.version.cxf}</version>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <artifactId>xml-apis</artifactId>
                <groupId>xml-apis</groupId>
            </exclusion>
            <exclusion>
                <artifactId>xercesImpl</artifactId>
                <groupId>xerces</groupId>
            </exclusion>
            <exclusion>
                <artifactId>xmlbeans</artifactId>
                <groupId>org.apache.xmlbeans</groupId>
            </exclusion>
            <exclusion>
                <artifactId>xmlParserAPIs</artifactId>
                <groupId>xerces</groupId>
            </exclusion>
        </exclusions>
    </dependency>

Hope this helps someone!

查看更多
登录 后发表回答