1
votes

I have a server side web app code which is using mule to consume xml messages and do some processing. Recently I have shifted to a new tomcat version. I am seeing following errors while mule tries to convert xml to dom.

Exception Stack trace: 

1. org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration (java.lang.ClassCastException) org.apache.xerces.parsers.DOMParser:-1 (null) 2. org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration (java.lang.ClassCastException) (org.mule.api.transformer.TransformerException) org.mule.module.xml.transformer.XmlToDomDocument:64 (http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/transformer/TransformerException.html)

Root Exception stack trace: java.lang.ClassCastException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration at org.apache.xerces.parsers.DOMParser.(Unknown Source) at org.apache.xerces.parsers.DOMParser.(Unknown Source) at org.apache.xerces.jaxp.DocumentBuilderImpl.(Unknown Source) at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)at com.sun.org.apache.xalan.internal.xsltc.trax.SAX2DOM.createDocument(SAX2DOM.java:324) at com.sun.org.apache.xalan.internal.xsltc.trax.SAX2DOM.(SAX2DOM.java:84) at com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory.getSerializationHandler(TransletOutputHandlerFactory.java:187) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getOutputHandler(TransformerImpl.java:392) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:298) at org.mule.module.xml.transformer.XmlToDomDocument.doTransform(XmlToDomDocument.java:58) at org.mule.transformer.AbstractTransformer.transform(AbstractTransformer.java:254)

I figured this is happening because of xerces 2.9.1 in my WEB-INF/lib director. I removed the jar and it worked all fine. The issue is that I neeed that jar in my lib as there is some other legacy 3rd pary jar in the lib which requires that vesion of xerces in classpath.

  1. Is there a way where i could specify a different DOM parser and make mule pick that up from the classpath.
  2. I checked the xerces java doc, XIncludeAwareParserConfiguration does implement XMLParserConfiguration. Wonder why is it throwing a classcast?

Thnks

1

1 Answers

0
votes

Mule's AbstractXmlTransformer offers several configuration options, including setXMLInputFactory which I believe should help you achieve your goal.

The problem is that these configuration options are not offered at XML level so you'd have to declare the XmlToDomDocument as a custom transformer in order to set different properties on it.