{"record":{"id":"d694e86d2944d95b","repo":"stanfordnlp/CoreNLP","slug":"serialization-failed-e-getmessage","errorCode":null,"errorMessage":"Serialization failed: ${e.getMessage()}","messagePattern":"Serialization failed: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/classify/LinearClassifier.java","lineNumber":1346,"sourceCode":"    try {\n      ObjectInputStream ois = IOUtils.readStreamFromString(loadPath);\n      LinearClassifier<L, F> classifier = ErasureUtils.<LinearClassifier<L, F>>uncheckedCast(ois.readObject());\n      ois.close();\n      return classifier;\n    } catch (Exception e) {\n      throw new RuntimeException(\"Deserialization failed: \"+e.getMessage(), e);\n    }\n  }\n\n  /**\n   * Convenience wrapper for IOUtils.writeObjectToFile.\n   */\n  public static void writeClassifier(LinearClassifier<?, ?> classifier, String serializePath) {\n    try {\n      IOUtils.writeObjectToFile(classifier, serializePath);\n      logger.info(\"Serializing classifier to \" + serializePath + \"... done.\");\n    } catch (Exception e) {\n      throw new RuntimeException(\"Serialization failed: \" + e.getMessage(), e);\n    }\n  }\n\n  /**\n   * Saves this out to a standard text file, instead of as a serialized Java object.\n   * NOTE: this currently assumes feature and weights are represented as Strings.\n   * @param file String filepath to write out to.\n   */\n  public void saveToFilename(String file) {\n    try {\n      File tgtFile = new File(file);\n      BufferedWriter out = new BufferedWriter(new FileWriter(tgtFile));\n      // output index first, blank delimiter, outline feature index, then weights\n      labelIndex.saveToWriter(out);\n      featureIndex.saveToWriter(out);\n      int numLabels = labelIndex.size();\n      int numFeatures = featureIndex.size();\n      for (int featIndex=0; featIndex<numFeatures; featIndex++) {","sourceCodeStart":1328,"sourceCodeEnd":1364,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/classify/LinearClassifier.java#L1328-L1364","documentation":"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.","triggerScenarios":"Thrown at src/edu/stanford/nlp/classify/LinearClassifier.java:1346 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}