stanfordnlp/CoreNLP · error · RuntimeIOException
Couldn't load
Error message
Couldn't load {file} What it means
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.
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
Example fix
// before <!-- corenlp 3.8 jar with corenlp models 3.4 (serialized class mismatch) --> // after <dependency>stanford-corenlp</dependency> <dependency>stanford-corenlp-models</dependency> <!-- same version as jar -->
Defensive patterns
Strategy: try-catch
Validate before calling
String f = props.getProperty("coref.gender.map") /* or default */;
if (f != null && !IOUtils.existsInClasspathOrFileSystem(f)) {
throw new IllegalStateException("Gender map not found: " + f);
} Try / catch
try {
new Dictionaries(props);
} catch (RuntimeIOException e) {
// also covers ClassNotFoundException cause for serialized map
log.error("Gender map load failed (check model/lib version match): " + e.getMessage(), e);
throw e;
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: Old CoreNLP model files with a newer jar (deserialization fails), missing models jar, truncated file, or wrong path in coref.gender properties.
Related errors
- Error loading classifier from
- Error reading saved links
- Error creating data exporter
- Error setting up training
- Error initializing FeatureExtractorRunner
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/31bae7757c6ae40c.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/dcoref/Dictionaries.java:396
/**
* Load Bergsma and Lin (2006) gender and number list.
* <br>
* The list is converted from raw text and numbers to a serialized
* map, which saves quite a bit of time loading.
* See edu.stanford.nlp.dcoref.util.ConvertGenderFile
*/
private void loadGenderNumber(String file, String neutralWordsFile) {
try {
getWordsFromFile(neutralWordsFile, neutralWords, false);
} catch (IOException e) {
throw new RuntimeIOException("Couldn't load " + neutralWordsFile);
}
try {
Map<List<String>, Gender> temp = IOUtils.readObjectFromURLOrClasspathOrFileSystem(file);
genderNumber.putAll(temp);
} catch (IOException | ClassNotFoundException e) {
throw new RuntimeIOException("Couldn't load " + file);
}
}
private static void loadCorefDict(String[] file,
ArrayList<Counter<Pair<String, String>>> dict) {
for(int i = 0; i < 4; i++){
dict.add(new ClassicCounter<>());
BufferedReader reader = null;
try {
reader = IOUtils.readerFromString(file[i]);
// Skip the first line (header)
reader.readLine();
while(reader.ready()) {
String[] split = reader.readLine().split("\t");
dict.get(i).setCount(new Pair<>(split[0], split[1]), Double.parseDouble(split[2]));View on GitHub (pinned to 1b7edd19c4)