{"record":{"id":"f1cd969ee4f5716c","repo":"stanfordnlp/CoreNLP","slug":"runtimeioexception-wrapping-ioexception-f1cd96","errorCode":null,"errorMessage":"RuntimeIOException wrapping IOException","messagePattern":"RuntimeIOException wrapping IOException","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/dcoref/Dictionaries.java","lineNumber":250,"sourceCode":"  }\n\n  /** The format of each line of this file is\n   *     fullStateName ( TAB  abbrev )*\n   *  The file is cased and checked cased.\n   *  The result is: statesAbbreviation is a hash from each abbrev to the fullStateName.\n   */\n  public void loadStateAbbreviation(String statesFile) {\n    BufferedReader reader = null;\n    try {\n      reader = IOUtils.readerFromString(statesFile);\n      for (String line; (line = reader.readLine()) != null; ) {\n        String[] tokens = line.split(\"\\t\");\n        for (String token : tokens) {\n          statesAbbreviation.put(token, tokens[0]);\n        }\n      }\n    } catch (IOException e) {\n      throw new RuntimeIOException(e);\n    } finally {\n      IOUtils.closeIgnoringExceptions(reader);\n    }\n  }\n\n  /** If the input string is an abbreviation of a U.S. state name\n   *  or the canonical name, the canonical name is returned.\n   *  Otherwise, null is returned.\n   *\n   *  @param name Is treated as a cased string. ME != me\n   */\n  public String lookupCanonicalAmericanStateName(String name) {\n    return statesAbbreviation.get(name);\n  }\n\n  /** The format of the demonyms file is\n   *     countryCityOrState ( TAB demonym )*\n   *  Lines starting with # are ignored","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/dcoref/Dictionaries.java#L232-L268","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n// default dict file missing at edu/stanford/nlp/models/dcoref/state-abbreviations.txt\n\n// after\n// restore the resource in the classpath or pass an explicit readable file:\nDictionaries dict = new Dictionaries(\n    \"default\",  // ensure this path exists and is readable\n    ...);","handlingStrategy":"try-catch","validationCode":"// Verify default dcoref resources exist on classpath before construction\nString[] required = {\n  \"/edu/stanford/nlp/models/dcoref/state-abbreviations.txt\" };\nfor (String r : required)\n  if (Dictionaries.class.getResource(r) == null)\n    throw new IllegalStateException(\"Missing dcoref resource: \" + r);","typeGuard":null,"tryCatchPattern":"try {\n  Dictionaries dict = new Dictionaries();\n} catch (RuntimeIOException e) {\n  logger.severe(\"Dictionary load failed (check cause): \" + e.getCause());\n  throw e;\n}","preventionTips":["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."],"tags":["java","io","resource-loading","checked-exception-wrapping","corenlp"],"backgroundTag":"file-not-found","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}