{"record":{"id":"10d8e6c9f7f7d655","repo":"stanfordnlp/CoreNLP","slug":"couldn-t-load-classifier-from-path","errorCode":null,"errorMessage":"Couldn't load classifier from {path}","messagePattern":"Couldn't load classifier from (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/ClassifierCombiner.java","lineNumber":297,"sourceCode":"    }\n  }\n\n\n  public static <INN extends CoreMap & HasWord> AbstractSequenceClassifier<INN> loadClassifierFromPath(Properties props, String path)\n      throws IOException {\n    //try loading as a CRFClassifier\n    try {\n      return ErasureUtils.uncheckedCast(CRFClassifier.getClassifier(path, props));\n    } catch (Exception e) {\n      e.printStackTrace();\n    }\n    //try loading as a CMMClassifier\n    try {\n      return ErasureUtils.uncheckedCast(CMMClassifier.getClassifier(path));\n    } catch (Exception e) {\n      //fail\n      //log.info(\"Couldn't load classifier from path :\"+path);\n      throw new IOException(\"Couldn't load classifier from \" + path, e);\n    }\n  }\n\n  @Override\n  public Set<String> labels() {\n    Set<String> labs = Generics.newHashSet();\n    for(AbstractSequenceClassifier<? extends CoreMap> cls: baseClassifiers)\n      labs.addAll(cls.labels());\n    return labs;\n  }\n\n\n  /**\n   * Reads the Answer annotations in the given labellings (produced by the base models)\n   *   and combines them using a priority ordering, i.e., for a given baseDocument all\n   *   labellings seen before in the baseDocuments list have higher priority.\n   *   Writes the answer to AnswerAnnotation in the labeling at position 0\n   *   (considered to be the main document).","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/ClassifierCombiner.java#L279-L315","documentation":"loadClassifierFromPath tries to load a classifier from a filesystem path, first as a CRFClassifier then as a CMMClassifier. If both attempts fail it wraps the last exception in an IOException saying the classifier could not be loaded from that path.","triggerScenarios":"Passing a nonexistent, unreadable, or non-classifier file path in the 'classifiers' property of NERClassifierCombiner/ClassifierCombiner, or a serialized model incompatible with the current library version.","commonSituations":"Typo'd classifier path in StanfordCoreNLP.properties; classifier file not shipped/deployed with the app; model trained/serialized with an older CoreNLP version; file permissions.","solutions":["Verify the path exists and is readable: new File(path).canRead()","Re-serialize the classifier with the CoreNLP version on your classpath","Check the 'classifiers' property value for typos and correct resource prefixes","Inspect the wrapped cause to distinguish file-not-found from deserialization issues"],"exampleFix":"// before\nprops.setProperty(\"classifiers\", \"models/my-ner-model.ser.gz\"); // file missing\n// after\nFile f = new File(\"models/my-ner-model.ser.gz\");\nif (!f.canRead()) throw new IllegalStateException(\"classifier missing: \" + f.getAbsolutePath());\nprops.setProperty(\"classifiers\", f.getAbsolutePath());","handlingStrategy":"validation","validationCode":"for (String path : classifierPaths) {\n  File f = new File(path);\n  if (!f.canRead()) throw new IllegalStateException(\"unreadable classifier: \" + f.getAbsolutePath());\n  try (ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(f)))) {\n    // force read of stream header to catch corruption early\n    in.available();\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  nerPipeline = new NERClassifierCombiner(props);\n} catch (IOException e) {\n  throw new RuntimeException(\"Check 'classifiers' property paths and model versions\", e);\n}","preventionTips":["Use absolute or verified classpath paths in the 'classifiers' property","Ship model files with the application and checksum them","Keep training and serving CoreNLP versions aligned"],"tags":["java","corenlp","classifier","file-not-found"],"backgroundTag":"resource-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"}