JAXP XSLT Transformer Using Incorrect Default Implementation

I have a Tomcat 5.5 web application that uses the Apache Commons-Configuration library to create an XML configuration file at runtime. Commons-Configuration, in turn, uses the javax.xml.transformJAXP API to accomplish this.

Starting with the upgrade to Java 7, the operation ends with an error message:

Caused by: javax.xml.transform.TransformerFactoryConfigurationError: Provider org.apache.xalan.processor.TransformerFactoryImpl not found
    at javax.xml.transform.TransformerFactory.newInstance(Unknown Source)

In past releases, I never added xalan.jar; instead, I relied on the default XSLT implementation of the platform.

Some things I checked:

  • There are no entries in any of the application JAR files, library banks, or Tomcat banks
META-INF/services/javax.xml.transform.TransformerFactory System property javax.xml.transform.TransformerFactorynot set (checked at runtime via JVisualVM) No file jaxp.propertiesin directoryjre/lib

Running with -Djaxp.debug=1leads to the following output:

JAXP: find factoryId =javax.xml.transform.TransformerFactory
JAXP: loaded from fallback value: org.apache.xalan.processor.TransformerFactoryImpl

Where does this reserve cost come from? Oracle sends the Xalan transformer, but since 1.7 repacked it as com.sun.org.apache.xalan.processor.... Shouldn't that be a fallback value?

+5
source share
2 answers

I found the question myself. It turns out that I had the files installed apache-tomcat-5.5.23-compat, since I was porting from Java 1.4.2. The solution was to delete everything in the directory $CATALINA_HOME/common/endorsed(in particular xercesImpl.jarand xml-apis.jar) and bin/jmx.jar.

+8
source

The same question I also got with the Glassfish V3.1 server, and placing xalan-2.7.0.jar in the $ GLASSFISH_HOME \ lib \ endorsed directory, the problem is fixed.

0
source

All Articles