stanfordnlp/CoreNLP · error · RuntimeException
Serialization failed
Error message
Serialization failed: ${e.getMessage()} What it means
RuntimeException wrapping any exception from LinearClassifier.writeClassifier when serializing the classifier to file — e.g., invalid path, no write permission, or disk full. The model could not be persisted.
Solutions
- Check the output directory exists and is writable
- Verify available disk space
- Retry with a different path; treat persistence as non-fatal if training can be redone
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at src/edu/stanford/nlp/classify/LinearClassifier.java:1346 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/d694e86d2944d95b.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/classify/LinearClassifier.java:1346
try {
ObjectInputStream ois = IOUtils.readStreamFromString(loadPath);
LinearClassifier<L, F> classifier = ErasureUtils.<LinearClassifier<L, F>>uncheckedCast(ois.readObject());
ois.close();
return classifier;
} catch (Exception e) {
throw new RuntimeException("Deserialization failed: "+e.getMessage(), e);
}
}
/**
* Convenience wrapper for IOUtils.writeObjectToFile.
*/
public static void writeClassifier(LinearClassifier<?, ?> classifier, String serializePath) {
try {
IOUtils.writeObjectToFile(classifier, serializePath);
logger.info("Serializing classifier to " + serializePath + "... done.");
} catch (Exception e) {
throw new RuntimeException("Serialization failed: " + e.getMessage(), e);
}
}
/**
* Saves this out to a standard text file, instead of as a serialized Java object.
* NOTE: this currently assumes feature and weights are represented as Strings.
* @param file String filepath to write out to.
*/
public void saveToFilename(String file) {
try {
File tgtFile = new File(file);
BufferedWriter out = new BufferedWriter(new FileWriter(tgtFile));
// output index first, blank delimiter, outline feature index, then weights
labelIndex.saveToWriter(out);
featureIndex.saveToWriter(out);
int numLabels = labelIndex.size();
int numFeatures = featureIndex.size();
for (int featIndex=0; featIndex<numFeatures; featIndex++) {View on GitHub (pinned to 1b7edd19c4)