stanfordnlp/CoreNLP · error · RuntimeIOException

Error loading classifier from

Error message

Error loading classifier from ${path}

What it means

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.

Solutions

  1. Confirm the classifier file path exists and is readable
  2. Re-serialize the classifier with the same Stanford NLP version used for loading
  3. Check that the file is a Java-serialized classifier, not a text model
  4. Catch the RuntimeException and retrain or fall back to a default classifier
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at src/edu/stanford/nlp/classify/ColumnDataClassifier.java:1961 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/956c41ab4487721b. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/classify/ColumnDataClassifier.java:1961

   *
   *  @param flagsClassifierPair A Pair of a Flags object array specifies all aspects of featurization
   *                             and other behavior and a Classifier that will be used.
   */
  public ColumnDataClassifier(Pair<Flags[],Classifier<String,String>> flagsClassifierPair) {
    flags = flagsClassifierPair.first();
    globalFlags = flags[0];
    classifier = flagsClassifierPair.second();
  }


  private static Pair<Flags[],Classifier<String,String>> loadClassifier(String path) {
    Timing t = new Timing();
    try (ObjectInputStream ois = IOUtils.readStreamFromString(path)) {
      Pair<Flags[],Classifier<String,String>> pair = loadClassifier(ois);
      t.done(logger, "Loading classifier from " + path);
      return pair;
    } catch (IOException | ClassNotFoundException e) {
      throw new RuntimeIOException("Error loading classifier from " + path, e);
    }
  }

  private static Pair<Flags[],Classifier<String,String>> loadClassifier(ObjectInputStream ois)
          throws IOException, ClassNotFoundException {
    // load the classifier
    Classifier<String,String> classifier = ErasureUtils.<LinearClassifier<String,String>>uncheckedCast(ois.readObject());
    Flags[] myFlags = (Flags[]) ois.readObject();
    assert myFlags.length > 0;
    return new Pair<>(myFlags, classifier);
  }

  /** Return a new ColumnDataClassifier object based on a serialized object.
   *  The serialized object stores both a Flags[] that specifies feature extraction and
   *  other properties of the classifier and a Classifier object.
   *
   *  @param path A classpath resource, URL, or file system path
   *  @return The ColumnDataClassifier

View on GitHub (pinned to 1b7edd19c4)