{"record":{"id":"66d5afc5cea340a8","repo":"stanfordnlp/CoreNLP","slug":"error-initializing-coref-system","errorCode":null,"errorMessage":"Error initializing coref system","messagePattern":"Error initializing coref system","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/coref/CorefSystem.java","lineNumber":44,"sourceCode":"/**\n * Class for running coreference algorithms\n * @author Kevin Clark\n */\npublic class CorefSystem {\n  private final DocumentMaker docMaker;\n  private final CorefAlgorithm corefAlgorithm;\n  private final boolean removeSingletonClusters;\n  private final boolean verbose;\n\n  public CorefSystem(Properties props) {\n    try {\n      Dictionaries dictionaries = new Dictionaries(props);\n      docMaker = new DocumentMaker(props, dictionaries);\n      corefAlgorithm = CorefAlgorithm.fromProps(props, dictionaries);\n      removeSingletonClusters = CorefProperties.removeSingletonClusters(props);\n      verbose = CorefProperties.verbose(props);\n    } catch (Exception e) {\n      throw new RuntimeException(\"Error initializing coref system\", e);\n    }\n  }\n\n  public CorefSystem(DocumentMaker docMaker, CorefAlgorithm corefAlgorithm,\n      boolean removeSingletonClusters, boolean verbose) {\n    this.docMaker = docMaker;\n    this.corefAlgorithm = corefAlgorithm;\n    this.removeSingletonClusters = removeSingletonClusters;\n    this.verbose = verbose;\n  }\n\n  public void annotate(Annotation ann) {\n    Document document;\n    try {\n      document = docMaker.makeDocument(ann);\n    } catch (Exception e) {\n      throw new RuntimeException(\"Error making document\", e);\n    }","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/coref/CorefSystem.java#L26-L62","documentation":"The CorefSystem constructor wraps all initialization (dictionaries, document maker, coref algorithm) in a try/catch and rethrows any failure as RuntimeException(\"Error initializing coref system\", e). It indicates a bad configuration or missing model/dictionary resources; the true cause is in the chained exception.","triggerScenarios":"Constructing new CorefSystem(Properties) where any of Dictionaries(props), DocumentMaker(props, dictionaries), or CorefAlgorithm.fromProps(props, dictionaries) throws — e.g. invalid property keys, missing model files, unreadable gender/dictionary data.","commonSituations":"Missing or mistyped coref.properties entries (ne demFile, singleton predictor model, algorithm name); coref models not on the classpath; running algorithm='neural' without the required model downloads; corrupted or incompatible model versions.","solutions":["Read the chained cause (e.getCause()) to find the actual failure and fix that root problem","Validate all coref properties (algorithm name, model paths, language) against the version's CorefProperties defaults","Ensure required coref models are downloaded and on the classpath (models jar matching your CoreNLP version)","Try a minimal default Properties() with just language=english to isolate which setting breaks init"],"exampleFix":"// before\nCorefSystem cs = new CorefSystem(badProps); // RuntimeException, cause hidden\n// after\ntry { CorefSystem cs = new CorefSystem(props); }\ncatch (RuntimeException e) { e.getCause().printStackTrace(); } // inspect real cause","handlingStrategy":"try-catch","validationCode":"Properties p = new Properties();\np.setProperty(\"annotators\", \"coref\");\np.setProperty(\"coref.algorithm\", \"statistical\");\n// verify required model resources exist before constructing\nif (getClass().getResource(\"/edu/stanford/nlp/models/coref/\") == null) {\n  throw new IllegalStateException(\"Coref models missing from classpath\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  CorefSystem cs = new CorefSystem(props);\n} catch (RuntimeException e) {\n  Throwable cause = e.getCause();\n  logger.log(Level.SEVERE, \"Coref init failed: \" + (cause == null ? e : cause), cause);\n  throw new IllegalStateException(\"Fix coref config/models; see cause\", e);\n}","preventionTips":["Always inspect getCause() — the wrapped exception names the real problem","Keep the CoreNLP models jar version-matched to the CoreNLP library","Validate coref properties keys/values against CorefProperties before construction","Test coref init with default properties in CI to catch model/classpath regressions"],"tags":["coref","initialization","configuration","runtime-exception"],"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"}