{"record":{"id":"a999f43233c27c77","repo":"stanfordnlp/CoreNLP","slug":"runtimeexception-wrapping-ioexception-a999f4","errorCode":null,"errorMessage":"RuntimeException wrapping IOException","messagePattern":"RuntimeException wrapping IOException","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/dcoref/Dictionaries.java","lineNumber":418,"sourceCode":"  private static void loadCorefDict(String[] file,\n      ArrayList<Counter<Pair<String, String>>> dict) {\n\n    for(int i = 0; i < 4; i++){\n      dict.add(new ClassicCounter<>());\n\n      BufferedReader reader = null;\n      try {\n        reader = IOUtils.readerFromString(file[i]);\n        // Skip the first line (header)\n        reader.readLine();\n\n        while(reader.ready()) {\n          String[] split = reader.readLine().split(\"\\t\");\n          dict.get(i).setCount(new Pair<>(split[0], split[1]), Double.parseDouble(split[2]));\n        }\n\n      } catch (IOException e) {\n        throw new RuntimeException(e);\n      } finally {\n        IOUtils.closeIgnoringExceptions(reader);\n      }\n    }\n  }\n\n  private static void loadCorefDictPMI(String file, Counter<Pair<String, String>> dict) {\n\n      BufferedReader reader = null;\n      try {\n        reader = IOUtils.readerFromString(file);\n        // Skip the first line (header)\n        reader.readLine();\n\n        while(reader.ready()) {\n          String[] split = reader.readLine().split(\"\\t\");\n          dict.setCount(new Pair<>(split[0], split[1]), Double.parseDouble(split[3]));\n        }","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/dcoref/Dictionaries.java#L400-L436","documentation":"loadCorefDict reads tab-separated coref dictionary files and rethrows any IOException as an unchecked RuntimeException wrapping it. It means one of the coreference dictionary resources (e.g. Bergsma-Lin lists) could not be opened or read.","triggerScenarios":"Constructing Dictionaries when any loadCorefDict input file path is wrong, the file is unreadable, or the stream throws while iterating reader.readLine().","commonSituations":"Missing CoreNLP models resources, misconfigured coref.dict.* properties, packaging that omits dictionary files, or permission/working-directory problems.","solutions":["Verify each coref dictionary file path in the properties exists and is readable","Ensure CoreNLP models jar is present on the classpath","Use classpath:/ URLs for bundled resources","Check file integrity (not truncated/empty) and permissions"],"exampleFix":"// before\nprops.setProperty(\"coref.dict1\", \"dict1.tsv\"); // relative, wrong cwd\n// after\nprops.setProperty(\"coref.dict1\", \"classpath:/edu/stanford/nlp/models/dcoref/dict1.txt\");","handlingStrategy":"try-catch","validationCode":"for (String key : new String[]{\"coref.dict1\",\"coref.dict2\",\"coref.dict3\",\"coref.dict4\"}) {\n    String v = props.getProperty(key);\n    if (v != null && !IOUtils.existsInClasspathOrFileSystem(v)) {\n        throw new IllegalStateException(key + \" file not found: \" + v);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    new Dictionaries(props);\n} catch (RuntimeException e) {\n    if (e.getCause() instanceof IOException) {\n        log.error(\"Coref dict file unreadable: \" + e.getCause().getMessage(), e);\n    }\n    throw e;\n}","preventionTips":["Verify all dict file paths before constructing Dictionaries","Bundle CoreNLP model resources with the deployment","Check permissions and working directory assumptions","Inspect e.getCause() (IOException) for the underlying file problem"],"tags":["io","java","corenlp","resource-loading"],"backgroundTag":"file-read-failed","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"}