{"record":{"id":"956c41ab4487721b","repo":"stanfordnlp/CoreNLP","slug":"error-loading-classifier-from-path","errorCode":null,"errorMessage":"Error loading classifier from ${path}","messagePattern":"Error loading classifier from (.+?)","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/classify/ColumnDataClassifier.java","lineNumber":1961,"sourceCode":"   *\n   *  @param flagsClassifierPair A Pair of a Flags object array specifies all aspects of featurization\n   *                             and other behavior and a Classifier that will be used.\n   */\n  public ColumnDataClassifier(Pair<Flags[],Classifier<String,String>> flagsClassifierPair) {\n    flags = flagsClassifierPair.first();\n    globalFlags = flags[0];\n    classifier = flagsClassifierPair.second();\n  }\n\n\n  private static Pair<Flags[],Classifier<String,String>> loadClassifier(String path) {\n    Timing t = new Timing();\n    try (ObjectInputStream ois = IOUtils.readStreamFromString(path)) {\n      Pair<Flags[],Classifier<String,String>> pair = loadClassifier(ois);\n      t.done(logger, \"Loading classifier from \" + path);\n      return pair;\n    } catch (IOException | ClassNotFoundException e) {\n      throw new RuntimeIOException(\"Error loading classifier from \" + path, e);\n    }\n  }\n\n  private static Pair<Flags[],Classifier<String,String>> loadClassifier(ObjectInputStream ois)\n          throws IOException, ClassNotFoundException {\n    // load the classifier\n    Classifier<String,String> classifier = ErasureUtils.<LinearClassifier<String,String>>uncheckedCast(ois.readObject());\n    Flags[] myFlags = (Flags[]) ois.readObject();\n    assert myFlags.length > 0;\n    return new Pair<>(myFlags, classifier);\n  }\n\n  /** Return a new ColumnDataClassifier object based on a serialized object.\n   *  The serialized object stores both a Flags[] that specifies feature extraction and\n   *  other properties of the classifier and a Classifier object.\n   *\n   *  @param path A classpath resource, URL, or file system path\n   *  @return The ColumnDataClassifier","sourceCodeStart":1943,"sourceCodeEnd":1979,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/classify/ColumnDataClassifier.java#L1943-L1979","documentation":"Wraps any exception raised while deserializing a serialized classifier in ColumnDataClassifier.loadClassifier. It fires when the classifier file path is wrong, the file is corrupt, the classpath resource is missing, or the serialized classes are incompatible.","triggerScenarios":"Thrown at src/edu/stanford/nlp/classify/ColumnDataClassifier.java:1961 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm the classifier file path exists and is readable","Re-serialize the classifier with the same Stanford NLP version used for loading","Check that the file is a Java-serialized classifier, not a text model","Catch the RuntimeException and retrain or fall back to a default classifier"],"exampleFix":null,"handlingStrategy":"fallback","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"}