JDK-8015487 : TransformerFactory.newTransformer crashing with external Xerces
  • Type: Bug
  • Component: xml
  • Sub-Component: jaxp
  • Affected Version: 7u40,8
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2013-05-28
  • Updated: 2015-03-27
  • Resolved: 2013-06-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Related Reports
Duplicate :  
This code snippet:
package transform.test;

import java.net.URL;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamSource;

public class TransformTest {
    public static void main(String[] args) throws Exception {
        TransformerFactory tf = TransformerFactory.newInstance();
        URL xsl = TransformTest.class.getResource("build.xsl");
        StreamSource stylesheetSource = new StreamSource(
            xsl.openStream(), xsl.toExternalForm());

may fail with the exception attached as "transformation-exception.txt" when xerces-2.8.0 is on the classpath.  The cause of this exception is
where the XMLConstants.ACCESS_EXTERNAL_DTD property is set into the parser, but the xerces-2.8.0 parser does not support the property.
This leads to the exception attached as "cannot-set-property.txt", which is then "transformed" into the originally described exception.

Presumably there should be a try-catch surrounding the setProperty to support parsers that do not know the XMLConstants.ACCESS_EXTERNAL_DTD property.

A binary test case and its sources is attached as testcase.zip. To reproduce:
1. unpack, go to the bin directory
2. run the test case as:
java -Djavax.xml.accessExternalDTD=all -Djavax.xml.accessExternalSchema=all -Djavax.xml.accessExternalStylesheet=all  -jar transform-test.jar 

This should lead to the exception attached as "transformation-exception.txt" when running on:
$ java -version
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b91)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b33, mixed mode)

The fix is in progress through JDK-8016153.