Java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl when starting weblogic

As part of our application, we use the apache xerces jaxp parser. When we deploy the application on weblogic 9.2, we get the following error.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.cxf.wsdl.WSDLManager' defined in class path resource [META-INF / cxf / cxf.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.apache.cxf.wsdl11.WSDLManagerImpl]: Constructor threw exception; nested exception is java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl

According to our analysis, weblogic is trying to load its own DocumentBuilderFactoryImpl, which is present in weblogic.jar instead of aper xerces.

We tried the following to make weblogic load DocumentBuilderFactoryImplfrom xerces

i) we added the following tag to weblogic.xml

<prefer-web-inf-classes>true</prefer-web-inf-classes>

ii) we installed the latest versions of xalan in the jre / lib / endorced folder. this did not solve our problem.

ii) we added entries to weblogic-application.xml

<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90">
 <application-param>
  <param-name>webapp.encoding.default</param-name>
  <param-value>UTF-8</param-value>
 </application-param>
 <prefer-application-packages>
  <package-name>javax.jws.*</package-name>
  <package-name>org.apache.xerces.*</package-name>
  <package-name>org.apache.xerces.jaxp.*</package-name>
 </prefer-application-packages>
</weblogic-application>

ii) Added the following entry to weblogic-application.xml

<xml> 
  <parser-factory> 
    <saxparser-factory>org.apache.xerces.jaxp.SAXParserFactoryImpl</saxparser-factory> 
    <document-builder-factory>org.apache.xerces.jaxp.DocumentBuilderFactoryImpl</document-builder-factory> 
    <transformer-factory>org.apache.xalan.processor.TransformerFactoryImpl</transformer-factory>
  </parser-factory> 
</xml>

iii) Added jaxp.propertiesto download DocumentBuilderFactoryImplfrom xerces in jre / lib and run the server. In this case, the web logic did not start.

iv) Then we first started the server and then copied the file jaxp.propertiesduring the server startup time. But no success

None of the above worked for us.

.

+3
4

, . WebLogic, WLS 9.2.

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90">
    <application-param>
        <param-name>webapp.encoding.default</param-name>
        <param-value>UTF-8</param-value>
    </application-param>
    <prefer-application-packages>
        <package-name>javax.jws.*</package-name>
    </prefer-application-packages>
</weblogic-application>

prefer-application-packages, Weblogic ClassLoader, , .


weblogic-application.xml :

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90">
    <xml>
      <parser-factory>
        <saxparser-factory>
          org.apache.xerces.jaxp.SAXParserFactoryImpl
        </saxparser-factory>
        <document-builder-factory>
          org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
        </document-builder-factory>
        <transformer-factory>
          org.apache.xalan.processor.TransformerFactoryImpl
        </transformer-factory>
      </parser-factory>
    </xml>
    <application-param>
        <param-name>webapp.encoding.default</param-name>
        <param-value>UTF-8</param-value>
    </application-param>
    <prefer-application-packages>
        <package-name>javax.jws.*</package-name>
        <package-name>org.apache.xerces.*</package-name>
        <package-name>org.apache.xalan.*</package-name>
    </prefer-application-packages>
</weblogic-application> 

.

+2

factory :

-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl

, Xerces factory .

, xerces.jar, - . Xerces JRE, com.sun.org.apache org.apache.

-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl

xerces.jar ( , WLS 10.3 Java 1.6).

+1

, . DocumentBuilderFactory.

xercesImpl.jar - MyDomain\servers\MyServer\lib.

+1

In my case, the problem was that I made a dependency on commons-digester , which in turn used a different version of xerces (which caused a conflict). Thus, you can view your dependencies in the case of a transit transfer of some other version of xerces .

0
source

Source: https://habr.com/ru/post/1736951/


All Articles