JDK8/JAXP 1.5 compatibility note
huizhe wang
huizhe.wang at oracle.com
Wed May 22 12:48:02 PDT 2013
Hi,
JAXP 1.5 is now in the JDK8 repository. Because of the incompatible
change, some in the dev teams have already felt the impact. I hope this
note may help you identify any issues related to the change.
Refer to http://openjdk.java.net/jeps/185:
In JDK8, the new external access properties introduced by JAXP 1.5 are
set to allow no access by default for DOM/SAX/StAX parsers and Schema
validation, and local file system for XSLT. Systems and applications
running on the latest JDK8 build may notice access errors if the
applications process XML files that require accessing external resources
such as DTD, XSD and XSL. The compatibility impact will be re-evaluated
later in JDK8, and the default setting may change following the evaluation.
The error messages in the current build will look like the following.
The message may change due to an enhancement request (JDK-8015016) that
called for improvement of the error messages.
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 163;
External DTD: Failed to read external DTD 'properties.dtd', because
'http' access is not allowed.
Below is a sample code to fix the issue using the new properties:
enableExternalAccess(parser, "http") ; // or "all" to allow all access
/**
* Configure the parser to allow external access to DTDs by the
protocol.
*/
public static void enableExternalAccess(SAXParser parser, String
protocol) throws SAXNotSupportedException {
try {
parser.setProperty("http://javax.xml.XMLConstants/property/accessExternalDTD",
protocol);
} catch (SAXNotRecognizedException ignore) {
// property requires >= JAXP 1.5
}
}
If it's desirable to remove the restriction for an entire application or
system, the system properties (such as javax.xml.accessExternalDTD in
this case) or jaxp.properties file may be used. Again, please see
http://openjdk.java.net/jeps/185 for more details.
Thanks,
Joe
More information about the jdk8-dev
mailing list