-
Sub-task
-
Resolution: Unresolved
-
P4
-
24
The JDK's XML [Processing Limits (known as JAXP Limits)](https://docs.oracle.com/en/java/javase/23/docs/api/java.xml/module-summary.html#IN_ISFPtable) are adjusted to be more in line with general applications. In particular, the default values of the limits are tuned down to more closely align with known DTDs.
If an application processes XML documents that reference an extremely large DTD, it may encounter a parsing error such as the follows:
JAXP00010001: The parser has encountered more than "2500" entity expansions in this document;
this is the limit imposed by the JDK.
To resolve the issue, application may increase the limit via the JAXP API. Using DOM processor as an example, the following code increases the expansion limit to 5000:
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setAttribute("jdk.xml.entityExpansionLimit", 5000);
Or in the JAXP Configuration File. A [template for creating Strict JAXP Configuration File](https://bugs.openjdk.org/browse/JDK-8330605), `jaxp-strict.properties.template`, was provided in JDK 23 for developers to assess and prepare their applications for the changes.
To set the property in the configuration file, copy the template and create a custom configuration file:
cp $JAVA_HOME/conf/jaxp-strict.properties.template. /<my_path>/jaxp-strict.properties
Edit and change the setting as follows:
jdk.xml.entityExpansionLimit=5000
As a system property, this property can also be set on the commandline, e.g.:
java -Djdk.xml.entityExpansionLimit=5000 myApp
The Java tutorial, [JAXP Processing Limits](https://docs.oracle.com/javase/tutorial//jaxp/limits/using.html), provides a debug solution that can be used to analyze the usages and estimate the limits.
If an application processes XML documents that reference an extremely large DTD, it may encounter a parsing error such as the follows:
JAXP00010001: The parser has encountered more than "2500" entity expansions in this document;
this is the limit imposed by the JDK.
To resolve the issue, application may increase the limit via the JAXP API. Using DOM processor as an example, the following code increases the expansion limit to 5000:
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setAttribute("jdk.xml.entityExpansionLimit", 5000);
Or in the JAXP Configuration File. A [template for creating Strict JAXP Configuration File](https://bugs.openjdk.org/browse/JDK-8330605), `jaxp-strict.properties.template`, was provided in JDK 23 for developers to assess and prepare their applications for the changes.
To set the property in the configuration file, copy the template and create a custom configuration file:
cp $JAVA_HOME/conf/jaxp-strict.properties.template. /<my_path>/jaxp-strict.properties
Edit and change the setting as follows:
jdk.xml.entityExpansionLimit=5000
As a system property, this property can also be set on the commandline, e.g.:
java -Djdk.xml.entityExpansionLimit=5000 myApp
The Java tutorial, [JAXP Processing Limits](https://docs.oracle.com/javase/tutorial//jaxp/limits/using.html), provides a debug solution that can be used to analyze the usages and estimate the limits.