stanfordnlp/CoreNLP · error · RuntimeIOException

argsToProperties could not read properties file: " + file

Error message

argsToProperties could not read properties file: " + file

What it means

When argsToProperties is given a filename (an argument beginning with a recognized file indicator) it tries to load that file as a Java properties file. If reading the file raises an IOException, the method rethrows it as RuntimeIOException('argsToProperties could not read properties file: <file>').

Solutions

  1. Verify the file path is correct and the file exists at the given (absolute or relative) location
  2. Pass an absolute path or run the program from the directory containing the properties file
  3. Check file read permissions for the user running the JVM
  4. Inspect the cause (getCause()) of the RuntimeIOException for the underlying IOException

Example fix

// before
java -cp ... Main -props confg.properties   // typo in filename
// after
java -cp ... Main -props /full/path/to/config.properties
Defensive patterns

Strategy: try-catch

Validate before calling

File f = new File(filename);
if (!f.isFile() || !f.canRead()) throw new IllegalStateException("Cannot read props file: " + f.getAbsolutePath());

Try / catch

try {
  Properties props = StringUtils.argsToProperties(args);
} catch (RuntimeIOException e) {
  log.fatal("Properties file unreadable: " + e.getMessage(), e.getCause());
  System.exit(1);
}

Prevention

When it happens

Trigger: Calling StringUtils.argsToProperties(args) (or the overload with a flags map) where the command line contains a filename argument and the file cannot be read: it doesn't exist, path is wrong, or I/O permissions block it.

Common situations: Command-line runs like '-props myprops.properties' with a typo'd or missing path; running from a different working directory with a relative path; missing read permissions in a cluster/CI environment.

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/c01ae35778e857c3. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/util/StringUtils.java:1060

    /* Processing in reverse order, add properties that aren't present only. Thus, later ones override earlier ones. */
    while (result.containsKey(PROPERTIES)) {
      String file = result.getProperty(PROPERTIES);
      if (LanguageInfo.isStanfordCoreNLPSupportedLang(file))
              file = LanguageInfo.getLanguagePropertiesFile(file);
      result.remove(PROPERTIES);
      Properties toAdd = new Properties();
      BufferedReader reader = null;
      try {
        reader = IOUtils.readerFromString(file);
        toAdd.load(reader);
        // trim all values
        for (String propKey : toAdd.stringPropertyNames()) {
          String newVal = toAdd.getProperty(propKey);
          toAdd.setProperty(propKey, newVal.trim());
        }
      } catch (IOException e) {
        String msg = "argsToProperties could not read properties file: " + file;
        throw new RuntimeIOException(msg, e);
      } finally {
        IOUtils.closeIgnoringExceptions(reader);
      }

      for (String key : toAdd.stringPropertyNames()) {
        String val = toAdd.getProperty(key);
        if ( ! result.containsKey(key)) {
          result.setProperty(key, val);
        }
      }
    }

    return result;
  }


  /**
   * This method reads in properties listed in a file in the format prop=value, one property per line.

View on GitHub (pinned to 1b7edd19c4)