stanfordnlp/CoreNLP · error · IllegalArgumentException

No model specified for Parser annotator

Error message

No model specified for Parser annotator ${annotatorName}

What it means

ParserAnnotator's constructor reads the model location from the property '<annotatorName>.model' (defaulting to LexicalizedParser.DEFAULT_PARSER_LOC) and throws IllegalArgumentException if the resolved value is null — meaning no parser model was configured.

Solutions

  1. Set the property '<annotatorName>.model' to a valid parser model path, e.g. stanfordCoreNLP.models=edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz
  2. Inspect your Properties object for explicit null values and remove/replace them
  3. Verify the annotator name used to construct ParserAnnotator matches the property prefix

Example fix

// before
props.put("parse.model", null);
ParserAnnotator p = new ParserAnnotator("parse", props);
// after
props.setProperty("parse.model", "edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz");
ParserAnnotator p = new ParserAnnotator("parse", props);
Defensive patterns

Strategy: validation

Validate before calling

if (props.getProperty(annotatorName + ".model") == null && LexicalizedParser.DEFAULT_PARSER_LOC == null) { props.setProperty(annotatorName + ".model", "edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz"); }

Try / catch

try { new ParserAnnotator("parse", props); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("No model specified")) { props.setProperty("parse.model", DEFAULT_MODEL); } else throw e; }

Prevention

When it happens

Trigger: Constructing ParserAnnotator with Properties that set the model property to an explicit null, or a properties mechanism that resolves annotatorName+".model" to null (e.g. a null entry stored programmatically).

Common situations: Programmatic Properties objects inserting null values; custom annotator names where the model key was never set while the default constant was overridden to null; typo'd annotator name in a wrapper that reads per-name properties.

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/bfa114229d47782f. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/pipeline/ParserAnnotator.java:121

    if (this.BUILD_GRAPHS) {
      TreebankLanguagePack tlp = parser.getTLPParams().treebankLanguagePack();
      this.gsf = tlp.grammaticalStructureFactory(tlp.punctuationWordRejectFilter(), parser.getTLPParams().typedDependencyHeadFinder());
    } else {
      this.gsf = null;
    }

    this.nThreads = 1;
    this.saveBinaryTrees = false;
    this.noSquash = false;
    this.extraDependencies = GrammaticalStructure.Extras.NONE;
    this.maxHeight = DEFAULT_MAX_HEIGHT;
  }


  public ParserAnnotator(String annotatorName, Properties props) {
    String model = props.getProperty(annotatorName + ".model", LexicalizedParser.DEFAULT_PARSER_LOC);
    if (model == null) {
      throw new IllegalArgumentException("No model specified for Parser annotator " + annotatorName);
    }
    this.VERBOSE = PropertiesUtils.getBool(props, annotatorName + ".debug", false);

    String[] flags = convertFlagsToArray(props.getProperty(annotatorName + ".flags"));
    this.parser = loadModel(model, VERBOSE, flags);
    this.maxSentenceLength = PropertiesUtils.getInt(props, annotatorName + ".maxlen", -1);
    this.maxHeight = PropertiesUtils.getInt(props, annotatorName + ".maxheight", DEFAULT_MAX_HEIGHT);

    String treeMapClass = props.getProperty(annotatorName + ".treemap");
    if (treeMapClass == null) {
      this.treeMap = null;
    } else {
      this.treeMap = ReflectionLoading.loadByReflection(treeMapClass, props);
    }

    this.maxParseTime = PropertiesUtils.getLong(props, annotatorName + ".maxtime", -1);

    this.kBest = PropertiesUtils.getInt(props, annotatorName + ".kbest", 1);

View on GitHub (pinned to 1b7edd19c4)