stanfordnlp/CoreNLP · error · RuntimeIOException

java.io.IOException

Error message

java.io.IOException

What it means

The StatTokSent constructor loads multi-word tokenizer rules from a file if one is configured. If reading those rules throws IOException, it is wrapped in RuntimeIOException. This means the rules file could not be read (missing, unreadable, or IO error mid-read).

Solutions

  1. Verify the multiWordRulesFile path exists and is readable at runtime (new File(path).canRead())
  2. Use an absolute path or resolve it against the classpath/resource and copy it out
  3. Omit the multi-word rules file argument to use the built-in default rules
  4. Run with the working directory you expect; relative paths resolve from CWD

Example fix

// before
new StatTokSent(modelFile, "rules/multiword.tsv"); // path missing on server
// after
String rules = locate("rules/multiword.tsv"); // resolve from classpath or absolute path
new StatTokSent(modelFile, rules);
Defensive patterns

Strategy: validation

Validate before calling

File f = new File(multiWordRulesFile);
if (!f.isFile() || !f.canRead()) throw new IllegalStateException("multiWordRulesFile unreadable: " + multiWordRulesFile);

Try / catch

try {
  new StatTokSent(modelFile, rulesFile);
} catch (RuntimeIOException e) {
  logger.warn("Rules file unreadable, using defaults", e);
  new StatTokSent(modelFile, null); // default multi word rules
}

Prevention

When it happens

Trigger: Constructing StatTokSent with a multiWordRulesFile path that doesn't exist or can't be opened/read — readMultiWordRules failing on a bad path or IO problem.

Common situations: Wrong relative path to the multiWordRules file; file exists in the repo but not on the deployment classpath/filesystem; permissions issues; passing a resource name where a filesystem path is required.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/process/stattok/StatTokSent.java:73

  public static final String SENTINEL = "\u00A7";

  /**
   * This is the constructor for the StatTokSent object.
   * Parameters:
   * 	modelFile: a string containing the path to the model;
   * 	multiWordRulesFile: a string containing the path to the file with multi-word tokens.
   */
  public StatTokSent(String modelFile, String multiWordRulesFile) {
    logger.info("Loading StatTokSent model from " + modelFile);
    if (multiWordRulesFile == null) {
      logger.info("Using default multi word rules");
    } else {
      logger.info("Using multi word rules from " + multiWordRulesFile);
      try {
        multiWordRules = this.readMultiWordRules(multiWordRulesFile);
      } catch (IOException e) {
        throw new RuntimeIOException(e);
      }
    }

    ObjectInputStream ois;

    try {
      ois = IOUtils.readStreamFromString(modelFile);
      cdc = ColumnDataClassifier.getClassifier(ois);
      this.windowSize = ois.readInt();
    } catch (IOException e) {
      throw new RuntimeIOException(e);
    } catch (ClassNotFoundException e) {
      throw new RuntimeClassNotFoundException(e);
    }

    logger.info("Found window size of " + this.windowSize);
  }

View on GitHub (pinned to 1b7edd19c4)