stanfordnlp/CoreNLP · error · IllegalArgumentException

annotator " " requires annotation " ". The usual…

Error message

annotator "%s" requires annotation "%s". The usual requirements for this annotator are: %s

What it means

StanfordCoreNLP's requirements-checking logic verifies, after adding each annotator, that every annotation class it requires (an.requirementCheck / unmet requirement) was satisfied by earlier annotators. If a requirement is missing it throws IllegalArgumentException naming the annotator, the missing annotation class, and the default requirements list.

Solutions

  1. Reorder/extend the annotators property so prerequisites run first, e.g. tokenize,ssplit,pos,lemma,ner,parse.
  2. Read the message's 'usual requirements' list and add annotators that satisfy the named missing annotation.
  3. For custom annotators, correctly declare requirementsSatisfied()/requirements() so the checker sees the produced annotations.

Example fix

// before
props.setProperty("annotators", "parse");
// after
props.setProperty("annotators", "tokenize,ssplit,pos,parse");
Defensive patterns

Strategy: validation

Validate before calling

// Use CoreNLP's own check before building:
Properties props = new Properties();
props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,parse");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props); // throws with the same message if requirements unmet — construct early
pipeline.annotate(annotation);

Try / catch

try {
  new StanfordCoreNLP(props).annotate(ann);
} catch (IllegalArgumentException e) {
  if (e.getMessage().contains("requires annotation")) {
    log.error("Pipeline misconfigured, fix annotator order: " + e.getMessage());
    throw new IllegalStateException("Invalid annotators property", e);
  }
  throw e;
}

Prevention

When it happens

Trigger: Declaring annotators in an order that leaves prerequisites unsatisfied (e.g. parse without tokenize/ssplit, ner without tokenize) so an earlier annotator never produced the required CoreAnnotations class.

Common situations: Hand-edited pipeline strings like annotators=parse or annotators=dcoref,semgraph; custom Annotator implementations whose REQUIREMENTS don't match what preceding annotators satisfy; dropping 'tokenize' to skip tokenization.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java:292

    Set<Class<? extends CoreAnnotation>> requirementsSatisfied = Generics.newHashSet();
    for (String name : annoNames) {
      name = name.trim();
      if (name.isEmpty()) { continue; }
      logger.info("Adding annotator " + name);

      Annotator an = pool.get(name);
      this.addAnnotator(an);

      if (enforceRequirements) {
        Set<Class<? extends CoreAnnotation>> allRequirements = an.requires();
        for (Class<? extends CoreAnnotation> requirement : allRequirements) {
          if (!requirementsSatisfied.contains(requirement)) {
            String fmt = "annotator \"%s\" requires annotation \"%s\". The usual requirements for this annotator are: %s";
            Collection<String> defaultRequirements = an.exactRequirements();
            if (defaultRequirements == null) {
              defaultRequirements = Annotator.DEFAULT_REQUIREMENTS.getOrDefault(name, Collections.singleton("unknown"));
            }
            throw new IllegalArgumentException(String.format(fmt, name, requirement.getSimpleName(), StringUtils.join(defaultRequirements, ",")));
          }
        }
        requirementsSatisfied.addAll(an.requirementsSatisfied());
      }

      alreadyAddedAnnoNames.add(name);
    }

    // Sanity check
    if (! alreadyAddedAnnoNames.contains(STANFORD_SSPLIT)) {
      System.setProperty(NEWLINE_SPLITTER_PROPERTY, "false");
    }
    this.pipelineSetupTime = tim.report();
  }

  /**
   * update the annotators, hopefully in a backwards compatible manner
   */

View on GitHub (pinned to 1b7edd19c4)