stanfordnlp/CoreNLP · error · IOException
Couldn't load classifier from
Error message
Couldn't load classifier from {path} What it means
loadClassifierFromPath tries to load a classifier from a filesystem path, first as a CRFClassifier then as a CMMClassifier. If both attempts fail it wraps the last exception in an IOException saying the classifier could not be loaded from that path.
Solutions
- Verify the path exists and is readable: new File(path).canRead()
- Re-serialize the classifier with the CoreNLP version on your classpath
- Check the 'classifiers' property value for typos and correct resource prefixes
- Inspect the wrapped cause to distinguish file-not-found from deserialization issues
Example fix
// before
props.setProperty("classifiers", "models/my-ner-model.ser.gz"); // file missing
// after
File f = new File("models/my-ner-model.ser.gz");
if (!f.canRead()) throw new IllegalStateException("classifier missing: " + f.getAbsolutePath());
props.setProperty("classifiers", f.getAbsolutePath()); Defensive patterns
Strategy: validation
Validate before calling
for (String path : classifierPaths) {
File f = new File(path);
if (!f.canRead()) throw new IllegalStateException("unreadable classifier: " + f.getAbsolutePath());
try (ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(f)))) {
// force read of stream header to catch corruption early
in.available();
}
} Try / catch
try {
nerPipeline = new NERClassifierCombiner(props);
} catch (IOException e) {
throw new RuntimeException("Check 'classifiers' property paths and model versions", e);
} Prevention
- Use absolute or verified classpath paths in the 'classifiers' property
- Ship model files with the application and checksum them
- Keep training and serving CoreNLP versions aligned
When it happens
Trigger: Passing a nonexistent, unreadable, or non-classifier file path in the 'classifiers' property of NERClassifierCombiner/ClassifierCombiner, or a serialized model incompatible with the current library version.
Common situations: Typo'd classifier path in StanfordCoreNLP.properties; classifier file not shipped/deployed with the app; model trained/serialized with an older CoreNLP version; file permissions.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Couldn't load classifier!
- TokensRegexNERAnnotator
- Shouldn't happen:
- Error reading saved links
- RuntimeIOException wrapping IOException
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/10d8e6c9f7f7d655.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/ie/ClassifierCombiner.java:297
}
}
public static <INN extends CoreMap & HasWord> AbstractSequenceClassifier<INN> loadClassifierFromPath(Properties props, String path)
throws IOException {
//try loading as a CRFClassifier
try {
return ErasureUtils.uncheckedCast(CRFClassifier.getClassifier(path, props));
} catch (Exception e) {
e.printStackTrace();
}
//try loading as a CMMClassifier
try {
return ErasureUtils.uncheckedCast(CMMClassifier.getClassifier(path));
} catch (Exception e) {
//fail
//log.info("Couldn't load classifier from path :"+path);
throw new IOException("Couldn't load classifier from " + path, e);
}
}
@Override
public Set<String> labels() {
Set<String> labs = Generics.newHashSet();
for(AbstractSequenceClassifier<? extends CoreMap> cls: baseClassifiers)
labs.addAll(cls.labels());
return labs;
}
/**
* Reads the Answer annotations in the given labellings (produced by the base models)
* and combines them using a priority ordering, i.e., for a given baseDocument all
* labellings seen before in the baseDocuments list have higher priority.
* Writes the answer to AnswerAnnotation in the labeling at position 0
* (considered to be the main document).View on GitHub (pinned to 1b7edd19c4)