{"record":{"id":"31bae7757c6ae40c","repo":"stanfordnlp/CoreNLP","slug":"couldn-t-load-file","errorCode":null,"errorMessage":"Couldn't load {file}","messagePattern":"Couldn't load (.+?)","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/dcoref/Dictionaries.java","lineNumber":396,"sourceCode":"\n  /**\n   * Load Bergsma and Lin (2006) gender and number list.\n   * <br>\n   * The list is converted from raw text and numbers to a serialized\n   * map, which saves quite a bit of time loading.\n   * See edu.stanford.nlp.dcoref.util.ConvertGenderFile\n   */\n  private void loadGenderNumber(String file, String neutralWordsFile) {\n    try {\n      getWordsFromFile(neutralWordsFile, neutralWords, false);\n    } catch (IOException e) {\n      throw new RuntimeIOException(\"Couldn't load \" + neutralWordsFile);\n    }\n    try {\n      Map<List<String>, Gender> temp = IOUtils.readObjectFromURLOrClasspathOrFileSystem(file);\n      genderNumber.putAll(temp);\n    } catch (IOException | ClassNotFoundException e) {\n      throw new RuntimeIOException(\"Couldn't load \" + file);\n    }\n  }\n\n  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]));","sourceCodeStart":378,"sourceCodeEnd":414,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/dcoref/Dictionaries.java#L378-L414","documentation":"loadGenderNumber throws RuntimeIOException(\"Couldn't load <file>\") when the serialized gender/number map cannot be read via IOUtils.readObjectFromURLOrClasspathOrFileSystem, or ClassNotFoundException if the serialized data was produced by an incompatible class version. It means the gender-number dictionary resource failed to load or deserialize.","triggerScenarios":"Constructing Dictionaries when the gender file is missing/unreadable, or the Java-serialized map's classes don't match the current CoreNLP serialVersionUID (model/code version mismatch).","commonSituations":"Old CoreNLP model files with a newer jar (deserialization fails), missing models jar, truncated file, or wrong path in coref.gender properties.","solutions":["Match the CoreNLP models version to the library version (re-download models jar)","Verify the gender file path exists and is readable","Use classpath:/ URL for the bundled resource","If ClassNotFoundException, regenerate the serialized gender file with edu.stanford.nlp.dcoref.util.ConvertGenderFile using the current library version"],"exampleFix":"// before\n<!-- corenlp 3.8 jar with corenlp models 3.4 (serialized class mismatch) -->\n// after\n<dependency>stanford-corenlp</dependency>\n<dependency>stanford-corenlp-models</dependency> <!-- same version as jar -->","handlingStrategy":"try-catch","validationCode":"String f = props.getProperty(\"coref.gender.map\") /* or default */;\nif (f != null && !IOUtils.existsInClasspathOrFileSystem(f)) {\n    throw new IllegalStateException(\"Gender map not found: \" + f);\n}","typeGuard":null,"tryCatchPattern":"try {\n    new Dictionaries(props);\n} catch (RuntimeIOException e) {\n    // also covers ClassNotFoundException cause for serialized map\n    log.error(\"Gender map load failed (check model/lib version match): \" + e.getMessage(), e);\n    throw e;\n}","preventionTips":["Keep CoreNLP and models jars at the SAME version (serialization compatibility)","Regenerate serialized gender files with ConvertGenderFile after upgrades","Verify file completeness after download","Use classpath:/ URLs for bundled resources"],"tags":["io","java","corenlp","deserialization","version-mismatch"],"backgroundTag":"class-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"}