15 September 2015

WebLogic Server XML Parsers

Many times there are question in WebLogic Server about parser factories:

java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature

  java.lang.ClassCastException: weblogic.xml.jaxp.RegistryXMLInputFactory cannot be cast to javax.xml.stream.XMLInputFactory
    Error weblogic.xml.jaxp.RegistryXMLInputFactory cannot be cast to javax.xml.stream.XMLInputFactory

 java.lang.NoSuchMethodError: javax.xml.parsers.DocumentBuilderFactory.newInstance(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljavax/xml/parsers/DocumentBuilderFactory;
java.lang.NoClassDefFoundError: org/apache/xerces/jaxp/datatype/XMLGregorianCalendarImpl$Parser




Because the classpath retrieve from different parts these implementations, including the JDK6 which bundles in it now.

This is how you can change by system properties the implementation, using xerces:

-Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl -Djavax.xml.parsers.SAXParser=org.apache.xerces.jaxp.SAXParserImpl

maybe you'll need to add xercesImpl.jar to your classpath. 



More info: 
https://docs.oracle.com/cd/E57014_01/wls/WLACH/pagehelp/Corexmlregistryxmlregistryconfigtitle.html



No comments :

My Blog List

Blog Archive

Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.