stanfordnlp/CoreNLP · error · RuntimeException
error:\n \ninput:\n \noutput:\n
Error message
error:\n%s\ninput:\n%s\noutput:\n%s
What it means
After running HeidelTime, its XML output is parsed with XMLUtils.parseElement; if parsing fails for any reason, the annotator throws a RuntimeException whose message embeds the exception, the raw input file contents, and HeidelTime's raw output, chaining the original cause. It indicates HeidelTime produced malformed, empty, or error output instead of valid Timex3 XML.
Solutions
- Read the embedded 'error:' cause and 'output:' in the message to see what HeidelTime actually printed.
- Fix HeidelTime configuration (language, resource path, tree tagger binaries) so it runs successfully.
- Run HeidelTime manually on the included inputFile contents to reproduce and diagnose.
- Validate that output is non-empty well-formed XML before calling toTimexCoreMaps if wrapping the annotator.
Example fix
// before (debugging)
throw new RuntimeException(String.format("error:\n%s\ninput:\n%s\noutput:\n%s", ex, in, out), ex);
// after: fix root cause, e.g. supply resource path
props.setProperty("heideltime.path", "/opt/heideltime/heideltime.sh");
props.setProperty("heideltime.language", "english"); Defensive patterns
Strategy: try-catch
Validate before calling
// Sanity-check the HeidelTime output before it reaches XML parsing
if (output == null || output.trim().isEmpty() || !output.trim().startsWith("<")) {
throw new IllegalStateException("HeidelTime returned non-XML output: " + output);
} Type guard
boolean looksLikeXml(String s) {
return s != null && s.trim().startsWith("<") && s.trim().endsWith(">");
} Try / catch
try {
heidelTimeAnnotator.annotate(annotation);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("error:")) {
logger.log(Level.SEVERE, "HeidelTime produced invalid XML; output was:\n" + e.getMessage(), e);
} else { throw e; }
} Prevention
- Verify HeidelTime's language/resource/TreeTagger configuration before deployment.
- Run HeidelTime manually once on a sample doc to confirm it emits well-formed Timex3 XML.
- Log HeidelTime's raw stdout/stderr in your wrapper to shorten diagnosis.
When it happens
Trigger: HeidelTime crashes or emits an error message (e.g. missing tree tagger models, bad language/resource config) so 'output' is not well-formed XML; output truncated or empty because the external process failed.
Common situations: Wrong heideltime language/resource properties causing the binary to print usage/errors; missing TreeTagger installation; locale or encoding problems corrupting the XML; an older HeidelTime version outputting a different format.
Related errors
- error:\n \ninput:\n \noutput:\n
- java.io.IOException
- CoreMap must have either a Calendar or DocDate annotation
- java.io.IOException
- addFeature was called with a features object that is…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/63ec13c670b5b6f7.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/time/HeidelTimeAnnotator.java:141
SystemUtils.run(process, outputWriter, null);
String output = outputWriter.getBuffer().toString();
Pattern docClose = Pattern.compile("</DOC>.*", Pattern.DOTALL);
output = docClose.matcher(output).replaceAll("</DOC>").replaceAll("<!DOCTYPE TimeML SYSTEM \"TimeML.dtd\">",""); //TODO TimeML.dtd? FileNotFoundException if we leave it in
Pattern badNestedTimex = Pattern.compile(Pattern.quote("<T</TIMEX3>IMEX3"));
output = badNestedTimex.matcher(output).replaceAll("</TIMEX3><TIMEX3");
Pattern badNestedTimex2 = Pattern.compile(Pattern.quote("<TI</TIMEX3>MEX3"));
output = badNestedTimex2.matcher(output).replaceAll("</TIMEX3><TIMEX3");
//output = output.replaceAll("\\n\\n<TimeML>\\n\\n","<TimeML>");
// These tags are needed for the xml to operate
//output = output.replaceAll("<TimeML>", "");
//output = output.replaceAll("</TimeML>", "");
// parse the HeidelTime output
Element outputXML;
try {
outputXML = XMLUtils.parseElement(output);
} catch (Exception ex) {
throw new RuntimeException(String.format("error:\n%s\ninput:\n%s\noutput:\n%s",
ex, IOUtils.slurpFile(inputFile), output), ex);
}
inputFile.delete();
// get Timex annotations
List<CoreMap> timexAnns = toTimexCoreMaps(outputXML, document);
document.set(TimeAnnotations.TimexAnnotations.class, timexAnns);
if (outputResults) {
System.out.println(timexAnns);
}
// align Timex annotations to sentences
int timexIndex = 0;
for (CoreMap sentence: document.get(CoreAnnotations.SentencesAnnotation.class)) {
int sentBegin = beginOffset(sentence);
int sentEnd = endOffset(sentence);
// skip times before the sentenceView on GitHub (pinned to 1b7edd19c4)