stanfordnlp/CoreNLP · warning

Error setting up

Error message

Error setting up 

What it means

After reflectively locating NERClassifierCombiner, setupNERTagger() fetches its static createNERClassifierCombiner(String, Properties) method and the classify(List) method. If method resolution or invocation fails (wrong signature due to a CoreNLP version change, reflective InvocationTargetException, or SecurityException), it logs 'Error setting up ...! Not applying NER tags!' and leaves NER tagging disabled.

Solutions

  1. Align all Stanford NLP jars to a single version; remove any standalone stanford-ner jar that shadows the CoreNLP-bundled classes.
  2. Instantiate NERClassifierCombiner directly instead of relying on the reflective path if you control the code, so version mismatches fail at compile time.
  3. Check the wrapped exception `ex` (InvocationTargetException cause) to identify the actual failure — often a missing model resource file.
  4. If NER enrichment is optional, accept the warning; conversion proceeds without NER tags.

Example fix

// before: mixed jars cause reflective Method lookup to fail
// classpath: stanford-corenlp-3.9.jar + stanford-ner-4.2.0.jar

// after: single consistent version
classpath = stanford-corenlp-4.5.0.jar:stanford-corenlp-4.5.0-models.jar
Defensive patterns

Strategy: validation

Validate before calling

// Verify the reflective API surface before relying on NER tagging
Class<?> c = Class.forName("edu.stanford.nlp.ie.NERClassifierCombiner");
Method create = c.getDeclaredMethod("createNERClassifierCombiner", String.class, Properties.class);
Method classify = c.getDeclaredMethod("classify", List.class);
if (create == null || classify == null) throw new IllegalStateException("NER API mismatch");

Type guard

if (NER_TAGGER != null && NER_CLASSIFY_METHOD != null) {
  NER_CLASSIFY_METHOD.invoke(NER_TAGGER, labels);
}

Try / catch

try {
  addNERTags(sg);
} catch (Exception e) {
  log.warn("NER tagging skipped: " + e.getCause(), e);
  // proceed without NER tags
}

Prevention

When it happens

Trigger: Calling addNERTags (hence convertTreeToBasic or main) when the loaded NER class does not expose createNERClassifierCombiner(String.class, Properties.class) or classify(List.class) — e.g. mixing CoreNLP and CoreNLP-ner jars from different versions, or a broken constructor path that throws inside createNERClassifierCombiner via Method.invoke.

Common situations: Version skew between stanford-corenlp and a separately installed stanford-ner jar on the classpath; API signature changes across CoreNLP major versions; a SecurityManager or module system (JPMS) blocking reflective access.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/trees/ud/UniversalDependenciesConverter.java:183

  private static Method NER_CLASSIFY_METHOD; // = null;

  /** Try to set up the NER tagger. **/
  @SuppressWarnings("unchecked")
  private static void setupNERTagger() {
    Class NER_TAGGER_CLASS;
    try {
      NER_TAGGER_CLASS = Class.forName(NER_COMBINER_NAME);
    } catch (Exception ex) {
      log.warn(  NER_COMBINER_NAME + " not found - not applying NER tags!");
      return;
    }
    try {
      Method createMethod = NER_TAGGER_CLASS.getDeclaredMethod("createNERClassifierCombiner",
                  String.class, Properties.class);
      NER_TAGGER = createMethod.invoke(null, null, new Properties());
      NER_CLASSIFY_METHOD = NER_TAGGER_CLASS.getDeclaredMethod("classify", List.class);
    } catch (Exception ex) {
      log.warn("Error setting up " + NER_COMBINER_NAME + "! Not applying NER tags!");
    }
  }

  /** Add NER tags to a semantic graph. **/
  private static void addNERTags(SemanticGraph sg) {
    // set up tagger if necessary
    if (NER_TAGGER == null || NER_CLASSIFY_METHOD == null) {
      setupNERTagger();
    }
    if (NER_TAGGER != null && NER_CLASSIFY_METHOD != null) {
      // we have everything successfully setup and so can act.
      try {
        // classify
        List<CoreLabel> labels =
            sg.vertexListSorted().stream().map(IndexedWord::backingLabel).collect(Collectors.toList());
        NER_CLASSIFY_METHOD.invoke(NER_TAGGER, labels);
      } catch (Exception ex) {
        log.warn("Error running " + NER_COMBINER_NAME + " on SemanticGraph!  Not applying NER tags!");

View on GitHub (pinned to 1b7edd19c4)