stanfordnlp/CoreNLP · error · RuntimeException
java.lang.Exception
Error message
java.lang.Exception
What it means
readSerializedProtobufFile deserializes an Annotation from a protobuf file and, on ANY Exception during reading/parsing/closing, wraps it in a RuntimeException at src/edu/stanford/nlp/quoteattribution/ExtractQuotesUtil.java:39. The message is generic because the original exception is only attached as the cause, so the real failure (IO error, protobuf parse failure, class mismatch) must be read from getCause().
Solutions
- Inspect the cause chain (getCause()) to find the real underlying error.
- Verify the file path exists and is readable before calling.
- Regenerate the serialized protobuf file with the exact CoreNLP version in use.
- Wrap the call in try-catch for RuntimeException and re-read the source file as plain text through the XML pipeline instead.
Example fix
// before
Annotation doc = ExtractQuotesUtil.readSerializedProtobufFile("quotes.ser");
// after
try {
Annotation doc = ExtractQuotesUtil.readSerializedProtobufFile("quotes.ser");
} catch (RuntimeException e) {
throw new IllegalStateException("Bad serialized quotes file: " + e.getCause(), e);
} Defensive patterns
Strategy: try-catch
Validate before calling
File f = new File(path); if (!f.isFile() || f.length() == 0) throw new FileNotFoundException(path);
Try / catch
try {
return ExtractQuotesUtil.readSerializedProtobufFile(path);
} catch (RuntimeException e) {
throw new IllegalStateException("Bad serialized file: " + e.getCause(), e);
} Prevention
- Serialize and deserialize with the same CoreNLP version
- Checksum serialized files and verify before loading
- Always log e.getCause(), not the wrapper
When it happens
Trigger: Calling ExtractQuotesUtil.readSerializedProtobufFile(path) where the file does not exist, is not a valid protobuf Annotation stream, was produced by an incompatible CoreNLP version, or the input stream fails mid-read.
Common situations: Pointing the quote attribution annotator at a serialized file saved by a different CoreNLP version; truncated or hand-edited .ser protobuf files; wrong file path passed as -quoteAttachment.
Understand the failure class
Background: "failed to unmarshal" / json.Unmarshal errors: why parsing a response into a Go struct fails and how to fix it — this error's family across 23 libraries.
Related errors
- Could not open temporary feature index file for reading.
- Serializing classifier to
- Failed to load segmenter
- Could not read string buffer fully!
- Keys are not being serialized: ${keysToSerialize}
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/4f6a5ee00f722268.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/quoteattribution/ExtractQuotesUtil.java:39
//return true if one is contained in the other.
public static boolean rangeContains(Pair<Integer, Integer> r1, Pair<Integer, Integer> r2) {
return ((r1.first <= r2.first && r1.second >= r2.first) || (r1.first <= r2.second && r1.second >= r2.second));
}
public static Annotation readSerializedProtobufFile(File fileIn)
{
Annotation annotation;
try {
ProtobufAnnotationSerializer pas = new ProtobufAnnotationSerializer();
InputStream is = new BufferedInputStream(new FileInputStream(fileIn));
Pair<Annotation, InputStream> pair = pas.read(is);
pair.second.close();
annotation = pair.first;
IOUtils.closeIgnoringExceptions(is);
return annotation;
}
catch(Exception e)
{
throw new RuntimeException(e);
}
}
}
View on GitHub (pinned to 1b7edd19c4)