stanfordnlp/CoreNLP · error · RuntimeIOException

java.io.IOException

Error message

java.io.IOException

What it means

HeidelTimeAnnotator.annotate() wraps the CoreMap-based annotate(), which shells out to the external HeidelTime binary via temporary files, in a catch of IOException rethrown as RuntimeIOException. It means the external HeidelTime process/file round-trip failed (binary missing, bad path, process error, or I/O failure).

Solutions

  1. Verify the heideltime.path (or equivalent property) points to an executable HeidelTime script and test running it manually.
  2. Catch RuntimeIOException around the annotate call and surface the underlying IOException's message.
  3. Ensure the temp/input directory is writable and the document text is non-empty and valid.
  4. Install HeidelTime (including its tree tagger dependency) and confirm Java compatibility.

Example fix

// before
pipeline.annotate(annotation); // RuntimeIOException bubbles up
// after
try {
  pipeline.annotate(annotation);
} catch (RuntimeIOException e) {
  logger.severe("HeidelTime failed: " + e.getCause());
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify HeidelTime is runnable before building the pipeline
Process p = new ProcessBuilder(heideltimePath, "--help").start();
if (p.waitFor(5, TimeUnit.SECONDS) && p.exitValue() != 0) {
  throw new IllegalStateException("HeidelTime not runnable at " + heideltimePath);
}

Type guard

boolean isHeidelTimeAvailable(String path) {
  return path != null && new File(path).canExecute();
}

Try / catch

try {
  heidelTimeAnnotator.annotate(annotation);
} catch (RuntimeIOException e) {
  IOException cause = (IOException) e.getCause();
  logger.log(Level.SEVERE, "HeidelTime I/O failure: " + cause.getMessage(), cause);
}

Prevention

When it happens

Trigger: Calling Annotator pipeline with HeidelTimeAnnotator when the configured heideltime path doesn't exist, the script isn't executable, or the external command writes to a missing/unwritable temp directory.

Common situations: HeidelTime not installed on the machine or path misconfigured in annotator properties; deploying to a container/image that lacks Java version or resources HeidelTime needs; read-only filesystem preventing temp file creation.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/time/HeidelTimeAnnotator.java:76

    this.heideltimePath = heideltimePath;
    this.outputResults = outputResults;
    this.language = language;
  }

  public HeidelTimeAnnotator(String name, Properties props) {
    this(new File(props.getProperty(HEIDELTIME_PATH_PROPERTY,
            System.getProperty("heideltime",
                    DEFAULT_PATH))),
        props.getProperty(HEIDELTIME_LANGUAGE_PROPERTY, "english"),
        Boolean.valueOf(props.getProperty(HEIDELTIME_OUTPUT_RESULTS, "false")));
  }

  @Override
  public void annotate(Annotation annotation) {
    try {
      this.annotate((CoreMap)annotation);
    } catch (IOException e) {
      throw new RuntimeIOException(e);
    }
  }

  public void annotate(CoreMap document) throws IOException {
    //--Create Input File
    //(create file)
    File inputFile = File.createTempFile("heideltime", ".input");
    //(write to file)
    PrintWriter inputWriter = new PrintWriter(inputFile);
    inputWriter.println(document.get(CoreAnnotations.TextAnnotation.class));
    inputWriter.close();

    //--Get Date
    //(error checks)
    if(!document.containsKey(CoreAnnotations.CalendarAnnotation.class) && !document.containsKey(CoreAnnotations.DocDateAnnotation.class)){
      throw new IllegalArgumentException("CoreMap must have either a Calendar or DocDate annotation"); //not strictly necessary, technically...
    }
    //(variables)

View on GitHub (pinned to 1b7edd19c4)