stanfordnlp/CoreNLP · error · RuntimeIOException
RuntimeIOException
Error message
RuntimeIOException
What it means
RuntimeIOException (a RuntimeException wrapper) is thrown when reading the serialized singleton predictor model file fails with an IOException — e.g. the file cannot be opened, is missing, or I/O fails mid-read. It surfaces IO problems from IOUtils.readStreamFromString / ObjectInputStream as an unchecked exception.
Solutions
- Check the model file path exists and is readable (ls / canRead)
- Correct the singletonModel (or equivalent) property to the right resource path
- Regenerate or re-download the model file if it is truncated/corrupt
- Catch RuntimeIOException around model loading to give a clearer user-facing error
Example fix
// before
SingletonPredictor predictor = SieveCoreferenceSystem.loadSingletonPredictor("models/single.ser");
// after
File f = new File("models/single.ser");
if (!f.exists() || !f.canRead()) throw new IllegalArgumentException("Missing singleton model: " + f);
SingletonPredictor predictor = SieveCoreferenceSystem.loadSingletonPredictor(f.getPath()); Defensive patterns
Strategy: try-catch
Validate before calling
File f = new File(path);
if (!f.exists()) throw new FileNotFoundException("Singleton model missing: " + path);
if (!f.canRead()) throw new IOException("No read permission: " + path); Try / catch
try {
SingletonPredictor p = SieveCoreferenceSystem.loadSingletonPredictor(path);
} catch (RuntimeIOException e) {
throw new IllegalStateException("Failed to load singleton predictor model at " + path, e);
} Prevention
- Verify model file paths at application startup
- Ship model files with the application or fail fast with clear messages
- Check file permissions in deployment environments
- Validate resource strings you pass to IOUtils.readStreamFromString
When it happens
Trigger: Calling the singleton predictor loader with a serializedFile path that does not exist, is not readable, is a directory, or whose stream errors during deserialization.
Common situations: Wrong model path in dcoref properties; model file not shipped/downloaded; running from a jar/resource path that doesn't resolve; permission problems on the model file.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- RuntimeIOException
- edu.stanford.nlp.io.RuntimeIOException
- Error reading saved links
- Wanted SingletonPredictor, got
- Invalid metricType
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/5a2a98c60d14bf5b.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/dcoref/SieveCoreferenceSystem.java:1045
}
for (int removeId : removeClusterSet){
document.corefClusters.remove(removeId);
}
for(Mention m : removeSet){
document.positions.remove(m);
}
}
public static LogisticClassifier<String, String> getSingletonPredictorFromSerializedFile(String serializedFile) {
try {
ObjectInputStream ois = IOUtils.readStreamFromString(serializedFile);
Object o = ois.readObject();
if (o instanceof LogisticClassifier<?, ?>) {
return (LogisticClassifier<String, String>) o;
}
throw new ClassCastException("Wanted SingletonPredictor, got " + o.getClass());
} catch (IOException e) {
throw new RuntimeIOException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
/** Remove singleton clusters */
public static List<List<Mention>> filterMentionsWithSingletonClusters(Document document, List<List<Mention>> mentions)
{
List<List<Mention>> res = new ArrayList<>(mentions.size());
for (List<Mention> ml:mentions) {
List<Mention> filtered = new ArrayList<>();
for (Mention m:ml) {
CorefCluster cluster = document.corefClusters.get(m.corefClusterID);
if (cluster != null && cluster.getCorefMentions().size() > 1) {
filtered.add(m);
}
}View on GitHub (pinned to 1b7edd19c4)