stanfordnlp/CoreNLP · error · RuntimeIOException
RuntimeIOException wrapping IOException
Error message
RuntimeIOException wrapping IOException
What it means
Dictionaries.loadStateAbbreviation reads a tab-separated state-abbreviation resource file line by line and builds the statesAbbreviation map. Any IOException while opening or reading the file is wrapped in an unchecked RuntimeIOException (reader closed in finally). It signals the bundled dictionary resource could not be loaded.
Solutions
- Read getCause() for the underlying IOException and confirm the exact resource path failing.
- Verify the CoreNLP distribution is complete — all default dictionary files present (re-download/re-extract if needed).
- Check that your build/packaging (shade/assembly) includes the dcoref resource files in the final jar.
- If providing custom dictionaries via Dictionaries constructor args, ensure the state-abbreviation file path is correct and readable.
- Confirm classloader visibility of resources (e.g. thread context classloader) in embedded/app-server environments.
Example fix
// before
// default dict file missing at edu/stanford/nlp/models/dcoref/state-abbreviations.txt
// after
// restore the resource in the classpath or pass an explicit readable file:
Dictionaries dict = new Dictionaries(
"default", // ensure this path exists and is readable
...); Defensive patterns
Strategy: try-catch
Validate before calling
// Verify default dcoref resources exist on classpath before construction
String[] required = {
"/edu/stanford/nlp/models/dcoref/state-abbreviations.txt" };
for (String r : required)
if (Dictionaries.class.getResource(r) == null)
throw new IllegalStateException("Missing dcoref resource: " + r); Try / catch
try {
Dictionaries dict = new Dictionaries();
} catch (RuntimeIOException e) {
logger.severe("Dictionary load failed (check cause): " + e.getCause());
throw e;
} Prevention
- Ship the complete CoreNLP distribution; verify after install.
- Check shade/assembly filters don't exclude .txt resources.
- Log getCause() of RuntimeIOException to find the exact file.
- In fat-jar/app-server setups, verify resource visibility of the classloader.
When it happens
Trigger: Constructing a Dictionaries instance when the state abbreviation resource file is missing from the classpath, corrupted, or unreadable — e.g. an incomplete CoreNLP distribution or a custom model jar missing default dictionary resources.
Common situations: Partially copied/extracted CoreNLP install missing lib resources; shading the jar and dropping resource files; custom classloader (app-server, fat jar) not exposing the resource; wrong defaultDictionary path in code.
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
- RuntimeException wrapping IOException
- Couldn't load
- RuntimeException wrapping IOException
- Error reading saved links
- Error creating data exporter
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/f1cd969ee4f5716c.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/dcoref/Dictionaries.java:250
}
/** The format of each line of this file is
* fullStateName ( TAB abbrev )*
* The file is cased and checked cased.
* The result is: statesAbbreviation is a hash from each abbrev to the fullStateName.
*/
public void loadStateAbbreviation(String statesFile) {
BufferedReader reader = null;
try {
reader = IOUtils.readerFromString(statesFile);
for (String line; (line = reader.readLine()) != null; ) {
String[] tokens = line.split("\t");
for (String token : tokens) {
statesAbbreviation.put(token, tokens[0]);
}
}
} catch (IOException e) {
throw new RuntimeIOException(e);
} finally {
IOUtils.closeIgnoringExceptions(reader);
}
}
/** If the input string is an abbreviation of a U.S. state name
* or the canonical name, the canonical name is returned.
* Otherwise, null is returned.
*
* @param name Is treated as a cased string. ME != me
*/
public String lookupCanonicalAmericanStateName(String name) {
return statesAbbreviation.get(name);
}
/** The format of the demonyms file is
* countryCityOrState ( TAB demonym )*
* Lines starting with # are ignoredView on GitHub (pinned to 1b7edd19c4)