views:

2012

answers:

3

As part of our application we are using apache's xerces jaxp parser. When we deploy the application on weblogic 9.2, we are getting 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

As per our analysis, weblogic is trying to to load its own DocumentBuilderFactoryImpl which is present in weblogic.jar instead of apache's xerces.

We tried the following to force the weblogic to load DocumentBuilderFactoryImpl from xerces

i) we have added the following tag into weblogic.xml

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

ii) we have put latest versions of xalan in jre/lib/endorced folder. this didn't resolve our problem.

ii) we have added entries in weblogic-application.xml

<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90"&gt;
 <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 in 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.properties to load DocumentBuilderFactoryImpl from xerces to the jre/lib and started the server.In this case, the weblogic didnt start.

iv) Then we started the server first and then copied the jaxp.properties file during the run time when server starts.But no success

None of the above worked for us.

Any help is highly appreciated.

+1  A: 

You did so many things that I don't understand the exact status. My advice would be to strictly follow the Application Server Specific Configuration Guide for WebLogic that I've successfully used in the past with WLS 9.2.

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90"&gt;
    <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>

You'll certainly have to add more packages under prefer-application-packages to setup Weblogic ClassLoader filtering but in the current state of the question, it's impossible to provide a precise answer.


Just in case, you can maybe try to blindly use the weblogic-application.xml from this thread:

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90"&gt;
    <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> 

But this is a shot in the dark.

Pascal Thivent
A: 

You could try forcing the use of the specified document builder factory as a command line option:

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

This is assuming that you have the required Xerces builder factory class in your classpath.

In general, you shouldn't use a separate xerces.jar anymore, unless required by some legacy code. The Xerces parser classes come with the JRE, the package names just start with com.sun.org.apache instead of org.apache. You could try also

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

and remove xerces.jar from your classpath altogether (this is what we did on WLS 10.3 and Java 1.6).

MarkoU
A: 

I have made the changes, regarding the classloader

javax.jws. org.apache.xerces. org.apache.xalan.*

And my Bea 9.2 MP3 running on jrockit 1.5 crashes with a memory dump! like never before.

I'm using CXF 2.2.9 and serialize my beans with xmlbeans

Mario
I changed the serialization to jaxb and it works! thanks!
Mario