stanfordnlp/CoreNLP · error · RuntimeException
Error configuring XML parser
Error message
Error configuring XML parser: ${e} What it means
TransformXML's constructor configures a secure SAXParserFactory. If the JAXP factory cannot be created or the secure-processing feature cannot be set, the exception is logged and rethrown as RuntimeException. This usually indicates a broken or unusual JAXP/SAX environment.
Solutions
- Remove conflicting XML parser jars (xerces, old SAX implementations) from the classpath so the JDK default parser is used
- If using a custom parser, upgrade it to one supporting FEATURE_SECURE_PROCESSING
- Set the system property javax.xml.parsers.SAXParserFactory explicitly to a working implementation
- Unwrap the cause (the RuntimeException's cause) to identify which setup step failed
Example fix
// before (classpath has stale xercesImpl-2.0.jar) java -cp lib/*:app.jar Main // after rm lib/xercesImpl-2.0.jar java -cp lib/*:app.jar Main
Defensive patterns
Strategy: try-catch
Validate before calling
try {
SAXParserFactory.newInstance().newSAXParser();
} catch (Exception e) {
throw new IllegalStateException("No working JAXP SAX parser on classpath", e);
} Try / catch
try {
new TransformXML<String>();
} catch (RuntimeException e) {
e.getCause().printStackTrace(); // parser config failure
} Prevention
- Keep only one XML parser implementation on the classpath
- Test JAXP parser availability at app startup
- Avoid embedding stale xerces/sax jars in fat JARs
When it happens
Trigger: Constructing TransformXML when SAXParserFactory.newInstance() returns a misconfigured factory, or spf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true) throws ParserConfigurationException/SAXNotRecognizedException — e.g. a non-standard JAXP implementation on the classpath.
Common situations: Conflicting XML parser jars (xercesImpl, old sax jars) shadowing the JDK's; running on restricted runtimes where FEATURE_SECURE_PROCESSING is unsupported; broken META-INF/services javax.xml.parsers.SAXParserFactory entry.
Related errors
- org.xml.sax.SAXException
- Unknown LogPriorType:
- unsupported language
- no sieve type specified
- Unknown minimizer
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/13f64a8dc7ec6ea5.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/process/TransformXML.java:203
@Override
public void processText(String text) {
if (text.length() > 0) {
text = function.apply(text).toString();
outWriter.print(text);
outWriter.print('\n');
}
}
}
public TransformXML() {
try {
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
saxParser = spf.newSAXParser();
} catch (Exception e) {
log.info("Error configuring XML parser: " + e);
throw new RuntimeException(e);
}
}
/**
* Read XML from the specified file and write XML to stdout,
* while transforming text appearing inside the specified XML
* tags by applying the specified {@link Function
* <code>Function</code>}. Note that the <code>Function</code>
* you supply must be prepared to accept <code>String</code>s as
* input; if your <code>Function</code> doesn't handle
* <code>String</code>s, you need to write a wrapper for it that
* does.
*
* @param tags an array of <code>String</code>s, each an XML tag
* within which the transformation should be applied
* @param fn the {@link Function <code>Function</code>} to apply
* @param in the <code>File</code> to read fromView on GitHub (pinned to 1b7edd19c4)