In my large project, the scaffman's answer would work all the time, but not on time, because we have several subprojects that depend on these libraries. We looked at the source at javax.xml.transform.TransformerFactory.newInstance () and found that it uses javax.xml.transform.FactoryFinder.find ("javax.xml.transform.TransformerFactory", ...). This method then checks the system parameter to determine the correct implementation.
We eventually fixed this by adding -d options to our runtime to force the correct classes:
-Djavax.xml.transform.TransformerFactory = org.apache.xalan.processor.TransformerFactoryImpl -Djavax.xml.parsers.SAXParserFactory = org.apache.xerces.jaxp.SAXParserFactoryImpl -Djavax.xml.perser. .jaxp.DocumentBuilderFactoryImpl
source share