{"record":{"id":"ad79ab065dff9a90","repo":"stanfordnlp/CoreNLP","slug":"error-setting-up","errorCode":null,"errorMessage":"Error setting up ","messagePattern":"Error setting up ","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/trees/ud/UniversalDependenciesConverter.java","lineNumber":183,"sourceCode":"  private static Method NER_CLASSIFY_METHOD; // = null;\n\n  /** Try to set up the NER tagger. **/\n  @SuppressWarnings(\"unchecked\")\n  private static void setupNERTagger() {\n    Class NER_TAGGER_CLASS;\n    try {\n      NER_TAGGER_CLASS = Class.forName(NER_COMBINER_NAME);\n    } catch (Exception ex) {\n      log.warn(  NER_COMBINER_NAME + \" not found - not applying NER tags!\");\n      return;\n    }\n    try {\n      Method createMethod = NER_TAGGER_CLASS.getDeclaredMethod(\"createNERClassifierCombiner\",\n                  String.class, Properties.class);\n      NER_TAGGER = createMethod.invoke(null, null, new Properties());\n      NER_CLASSIFY_METHOD = NER_TAGGER_CLASS.getDeclaredMethod(\"classify\", List.class);\n    } catch (Exception ex) {\n      log.warn(\"Error setting up \" + NER_COMBINER_NAME + \"! Not applying NER tags!\");\n    }\n  }\n\n  /** Add NER tags to a semantic graph. **/\n  private static void addNERTags(SemanticGraph sg) {\n    // set up tagger if necessary\n    if (NER_TAGGER == null || NER_CLASSIFY_METHOD == null) {\n      setupNERTagger();\n    }\n    if (NER_TAGGER != null && NER_CLASSIFY_METHOD != null) {\n      // we have everything successfully setup and so can act.\n      try {\n        // classify\n        List<CoreLabel> labels =\n            sg.vertexListSorted().stream().map(IndexedWord::backingLabel).collect(Collectors.toList());\n        NER_CLASSIFY_METHOD.invoke(NER_TAGGER, labels);\n      } catch (Exception ex) {\n        log.warn(\"Error running \" + NER_COMBINER_NAME + \" on SemanticGraph!  Not applying NER tags!\");","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/ud/UniversalDependenciesConverter.java#L165-L201","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Align all Stanford NLP jars to a single version; remove any standalone stanford-ner jar that shadows the CoreNLP-bundled classes.","Instantiate NERClassifierCombiner directly instead of relying on the reflective path if you control the code, so version mismatches fail at compile time.","Check the wrapped exception `ex` (InvocationTargetException cause) to identify the actual failure — often a missing model resource file.","If NER enrichment is optional, accept the warning; conversion proceeds without NER tags."],"exampleFix":"// before: mixed jars cause reflective Method lookup to fail\n// classpath: stanford-corenlp-3.9.jar + stanford-ner-4.2.0.jar\n\n// after: single consistent version\nclasspath = stanford-corenlp-4.5.0.jar:stanford-corenlp-4.5.0-models.jar","handlingStrategy":"validation","validationCode":"// Verify the reflective API surface before relying on NER tagging\nClass<?> c = Class.forName(\"edu.stanford.nlp.ie.NERClassifierCombiner\");\nMethod create = c.getDeclaredMethod(\"createNERClassifierCombiner\", String.class, Properties.class);\nMethod classify = c.getDeclaredMethod(\"classify\", List.class);\nif (create == null || classify == null) throw new IllegalStateException(\"NER API mismatch\");","typeGuard":"if (NER_TAGGER != null && NER_CLASSIFY_METHOD != null) {\n  NER_CLASSIFY_METHOD.invoke(NER_TAGGER, labels);\n}","tryCatchPattern":"try {\n  addNERTags(sg);\n} catch (Exception e) {\n  log.warn(\"NER tagging skipped: \" + e.getCause(), e);\n  // proceed without NER tags\n}","preventionTips":["Pin all Stanford NLP artifacts to one version in your dependency management.","Prefer direct API usage over the reflective path when possible for compile-time checking.","Log the InvocationTargetException cause to see the real failure behind reflective errors.","Upgrade CoreNLP as a set (core jar + models jar together), never one at a time."],"tags":["reflection","version-mismatch","ner","nlp","method-not-found"],"backgroundTag":"module-init-failed","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}