stanfordnlp/CoreNLP · critical · RuntimeIOException

java.io.IOException

Error message

java.io.IOException

What it means

The Annotation-level HeidelTimeKBPAnnotator.annotate runs the internal CoreMap annotate, which performs I/O (temp file creation, launching the external heideltime.jar process). Any IOException is rethrown as a RuntimeIOException, so failures spawning/communicating with the external HeidelTime tool surface as this unchecked exception.

Solutions

  1. Set the 'heideltime.path' property (or -Dheideltime system property) to the directory containing heideltime.jar and config.props
  2. Verify 'java -jar <path>/heideltime.jar' runs manually from the command line
  3. Check the printed stack trace (the underlying IOException cause) to distinguish file-creation vs process-start failures
  4. Ensure a Java runtime is on PATH and the temp directory (java.io.tmpdir) is writable

Example fix

// before
props.put("annotators", "tokenize,ssplit,pos,heideltimekb");
// after
props.setProperty("heideltime.path", "/opt/heideltime");  // dir with heideltime.jar + config.props
props.put("annotators", "tokenize,ssplit,pos,heideltimekb");
Defensive patterns

Strategy: try-catch

Validate before calling

File dir = new File(props.getProperty("heideltime.path", "/u/roland/heideltime"));
if (!new File(dir, "heideltime.jar").canRead()) {
    throw new IllegalStateException("heideltime.jar not found under " + dir);
}
if (!new File(dir, "config.props").canRead()) {
    throw new IllegalStateException("config.props not found under " + dir);
}

Try / catch

try {
    pipeline.annotate(annotation);
} catch (RuntimeIOException e) {
    logger.severe("HeidelTime I/O failure: " + e.getCause());
    // degrade gracefully: continue without TimexAnnotations
}

Prevention

When it happens

Trigger: Calling the heideltimekb annotator on an Annotation when: heideltime.path points to a directory without heideltime.jar or config.props (process fails to start), Java cannot create the temp input file, or the spawned HeidelTime process fails with an I/O error.

Common situations: Misconfigured 'heideltime.path' property (missing installation), heideltime.jar incompatible with the installed JDK, read-only temp directory, PATH lacking a usable 'java' executable.

Understand the failure class

Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/c465aa541ff53bd3. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/time/HeidelTimeKBPAnnotator.java:77

  }

  public HeidelTimeKBPAnnotator(String name, Properties props) {
    this.heideltimePath = new File(props.getProperty(HEIDELTIME_PATH_PROPERTY,
            System.getProperty("heideltime",
                    DEFAULT_PATH)));
    this.outputResults = Boolean.valueOf(props.getProperty(HEIDELTIME_OUTPUT_RESULTS, "false"));
    this.language = props.getProperty(HEIDELTIME_LANGUAGE_PROPERTY, "english");
//    this.tagList = Arrays.asList(props.getProperty("clean.xmltags", "").toLowerCase().split("\\|"))
//        .stream().filter(x -> x.length() > 0)
//        .collect(Collectors.toList());
  }

  @Override
  public void annotate(Annotation annotation) {
    try {
      this.annotate((CoreMap)annotation);
    } catch (IOException e) {
      throw new RuntimeIOException(e);
    }
  }
  private static final Map<String, String> TRANSLATE = new HashMap<String, String>() {{
    this.put("*NL*", "\n");
  }};
  public void annotate(CoreMap document) throws IOException {
    try {

      //--Create Input File
      //(create file)
      File inputFile = File.createTempFile("heideltime", ".input");
      //(write to file)
      PrintWriter inputWriter = new PrintWriter(inputFile);
      prepareHeidelTimeInput(inputWriter, document);
      inputWriter.close();
      Optional<String> pubDate = getPubDate(document);

      //--Build Command

View on GitHub (pinned to 1b7edd19c4)