{"record":{"id":"6b0371e10eccb91c","repo":"stanfordnlp/CoreNLP","slug":"invalid-model-at-path-serializedmodel","errorCode":null,"errorMessage":"Invalid model at path: \" + serializedModel","messagePattern":"Invalid model at path: \" \\+ serializedModel","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/naturalli/ClauseSplitter.java","lineNumber":289,"sourceCode":"  }\n\n\n  /**\n   * Load a factory model from a given path. This can be trained with\n   * {@link ClauseSplitter#train(Stream, Optional, Optional, Featurizer)}.\n   *\n   * @return A function taking a dependency tree, and returning a clause searcher.\n   */\n  static ClauseSplitter load(String serializedModel) throws IOException {\n    try {\n      long start = System.currentTimeMillis();\n      Pair<Classifier<ClauseClassifierLabel,String>, Featurizer> data = IOUtils.readObjectFromURLOrClasspathOrFileSystem(serializedModel);\n      ClauseSplitter rtn =  (tree, truth) -> new ClauseSplitterSearchProblem(tree, truth, Optional.of(data.first), Optional.of(data.second));\n      log.info(\"Loading clause splitter from \" + serializedModel + \" ... done [\" +\n              Redwood.formatTimeDifference(System.currentTimeMillis() - start) + \"]\");\n      return rtn;\n    } catch (ClassNotFoundException e) {\n      throw new IllegalStateException(\"Invalid model at path: \" + serializedModel, e);\n    }\n  }\n\n\n}\n","sourceCodeStart":271,"sourceCodeEnd":295,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/naturalli/ClauseSplitter.java#L271-L295","documentation":"ClauseSplitter.load deserializes a pretrained clause-splitter model from a URL, classpath, or filesystem path. If deserialization throws ClassNotFoundException — meaning the stream contained classes not present/resolvable in the current classpath — it reports the model as invalid via IllegalStateException.","triggerScenarios":"Loading a model serialized with a different Stanford NLP version whose class names or serialVersionUID changed, or a corrupted/wrong file at serializedModel that still deserializes far enough to reference unknown classes.","commonSituations":"Upgrading the CoreNLP/naturalli jar while keeping an old clause splitter model; classpath missing the naturalli classes when loading on a slim deployment; renaming/refactoring packages across versions.","solutions":["Align the library version with the one that trained/saved the model (check model README/version metadata)","Re-train or re-download a model compatible with your current CoreNLP version","Ensure the full naturalli/classifier classes are on the classpath (fat jar, correct dependencies)"],"exampleFix":"// before\nClauseSplitter splitter = ClauseSplitter.load(\"clauseSplitterModel-3.6.ser.gz\"); // with CoreNLP 4.x\n// after\n// download the model matching your CoreNLP version\nClauseSplitter splitter = ClauseSplitter.load(\"clauseSplitterModel-4.x.ser.gz\");","handlingStrategy":"fallback","validationCode":"// Confirm the resource exists and the expected classes are loadable before load()\nif (ClauseSplitter.class.getClassLoader().getResource(\"edu/stanford/nlp/naturalli/ClauseSplitterSearchProblem.class\") == null) {\n  throw new IllegalStateException(\"naturalli classes missing from classpath\");\n}","typeGuard":null,"tryCatchPattern":"try { return ClauseSplitter.load(modelPath); } catch (IllegalStateException e) { /* fallback to default/other model or re-download */ }","preventionTips":["Match model files to library versions explicitly","Bundle models with the jar version that trained them","Smoke-test model loading at startup, not lazily"],"tags":["java","model-loading","classpath","version-mismatch"],"backgroundTag":"class-not-found","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}