stanfordnlp/CoreNLP · error · RuntimeIOException
RuntimeIOException
Error message
RuntimeIOException
What it means
SingletonPredictor.saveToSerialized wraps any IOException that occurs while opening or writing the ObjectOutputStream for the model file in a RuntimeIOException and rethrows it. This converts a checked I/O failure during model persistence into an unchecked exception.
Solutions
- Ensure the target directory exists and is writable before calling saveToSerialized
- Use a plain writable file path rather than an invalid IOUtils resource string
- Check disk space/quota if the failure occurs mid-write
- Catch RuntimeIOException to translate it into a clear save-failure message
Example fix
// before
predictor.saveToSerialized("out/singleton.ser");
// after
new File("out").mkdirs();
predictor.saveToSerialized("out/singleton.ser"); Defensive patterns
Strategy: try-catch
Validate before calling
File out = new File(filename);
File parent = out.getAbsoluteFile().getParentFile();
if (parent != null && !parent.isDirectory() && !parent.mkdirs()) throw new IOException("Cannot create dir " + parent);
if (out.exists() && !out.canWrite()) throw new IOException("Not writable: " + out); Try / catch
try {
predictor.saveToSerialized(filename);
} catch (RuntimeIOException e) {
log.severe("Saving singleton predictor failed: " + e.getCause());
throw e;
} Prevention
- Create output directories before saving models
- Check disk space before long training jobs
- Use absolute, writable paths for model output
- Wrap save calls so I/O failures surface with context
When it happens
Trigger: Calling SingletonPredictor.saveToSerialized(filename) when the output path cannot be opened (bad path, unwritable directory, invalid URL-style resource specification via IOUtils.writeStreamFromString) or the write itself fails (disk full, stream closed).
Common situations: Saving trained predictor to a nonexistent directory; lacking write permissions; typos in the output filename/resource string; disk quota exceeded during training pipelines.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- RuntimeIOException
- RuntimeIOException wrapping IOException
- Error creating data exporter
- RuntimeException with no message (model write failure)
- RuntimeIOException wrapping IOException
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/5cf96f442da8ea64.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/dcoref/SingletonPredictor.java:150
LogisticClassifier<String, String> classifier = lcf.trainClassifier(pDataset);
return classifier;
}
/**
* Saves the singleton predictor model to the given filename.
* If there is an error, a RuntimeIOException is thrown.
*/
private static void saveToSerialized(LogisticClassifier<String, String> predictor,
String filename) {
try {
log.info("Writing singleton predictor in serialized format to file " + filename + ' ');
ObjectOutputStream out = IOUtils.writeStreamFromString(filename);
out.writeObject(predictor);
out.close();
log.info("done.");
} catch (IOException ioe) {
throw new RuntimeIOException(ioe);
}
}
public static void main(String[] args) throws Exception {
Properties props;
if (args.length > 0) {
props = StringUtils.argsToProperties(args);
} else {
props = new Properties();
}
if ( ! props.containsKey("dcoref.conll2011")) {
log.info("-dcoref.conll2011 [input_CoNLL_corpus]: was not specified");
return;
}
if ( ! props.containsKey("singleton.predictor.output")) {
log.info("-singleton.predictor.output [output_model_file]: was not specified");
return;
}View on GitHub (pinned to 1b7edd19c4)