{"record":{"id":"874c96ea4095fa83","repo":"stanfordnlp/CoreNLP","slug":"error-setting-up-training","errorCode":null,"errorMessage":"Error setting up training","messagePattern":"Error setting up training","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/coref/statistical/Clusterer.java","lineNumber":102,"sourceCode":"        modelName + \"/\";\n    File outDir = new File(outputPath);\n    if (!outDir.exists()) {\n      outDir.mkdir();\n    }\n\n    PrintWriter progressWriter;\n    List<ClustererDoc> trainDocs;\n    try {\n      PrintWriter configWriter = new PrintWriter(outputPath + \"config\", \"UTF-8\");\n      configWriter.print(StatisticalCorefTrainer.fieldValues(this));\n      configWriter.close();\n      progressWriter = new PrintWriter(outputPath + \"progress\", \"UTF-8\");\n\n      Redwood.log(\"scoref.train\", \"Loading training data\");\n      StatisticalCorefTrainer.setDataPath(\"dev\");\n      trainDocs = ClustererDataLoader.loadDocuments(MAX_DOCS);\n    } catch (Exception e) {\n      throw new RuntimeException(\"Error setting up training\", e);\n    }\n\n    double bestTrainScore = 0;\n    List<List<Pair<CandidateAction, CandidateAction>>> examples = new ArrayList<>();\n    for (int iteration = 0; iteration < RETRAIN_ITERATIONS; iteration++) {\n      Redwood.log(\"scoref.train\", \"ITERATION \" + iteration);\n      classifier.printWeightVector(null);\n      Redwood.log(\"scoref.train\", \"\");\n      try {\n        classifier.writeWeights(outputPath + \"model\");\n        classifier.printWeightVector(IOUtils.getPrintWriter(outputPath + \"weights\"));\n      } catch (Exception e) {\n        throw new RuntimeException();\n      }\n\n      long start = System.currentTimeMillis();\n      Collections.shuffle(trainDocs, random);\n","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/coref/statistical/Clusterer.java#L84-L120","documentation":"Clusterer.doTraining sets up output writers and loads dev-set documents; any Exception during this setup phase is wrapped in RuntimeException(\"Error setting up training\"). It signals that statistical-coref clusterer training could not even begin (model file, progress file, or training data problems).","triggerScenarios":"Running statistical coref training where the output path/model file cannot be opened, the 'progress' writer cannot be created (e.g. unsupported charset or unwritable path), or ClustererDataLoader.loadDocuments fails to read dev data.","commonSituations":"Missing dev data files at the configured data path; outputPath property pointing to a non-existent directory; running the trainer outside the models/ directory layout it expects.","solutions":["Ensure outputPath exists and is writable before training (create the directory, check 'progress' can be written)","Verify the dev data path (StatisticalCorefTrainer.setDataPath(\"dev\")) points to a directory with the expected conll/gold files","Check the model file for the classifier is present and loadable","Inspect e.getCause() to see whether it was the writer or the data loading that failed"],"exampleFix":"// before\njava edu.stanford.nlp.coref.statistical.ClustererTrain  // outputPath=nonexistent/dir\n// after\nmkdir -p nonexistent/dir   # and ensure dev data exists at configured dataPath\njava edu.stanford.nlp.coref.statistical.ClustererTrain","handlingStrategy":"validation","validationCode":"java.io.File out = new java.io.File(outputPath);\nif (!out.isDirectory() && !out.mkdirs()) throw new IllegalStateException(\"bad outputPath\");\nif (!out.canWrite()) throw new IllegalStateException(\"outputPath not writable\");\njava.io.File dev = new java.io.File(dataPath, \"dev\");\nif (!dev.isDirectory()) throw new IllegalStateException(\"dev data missing at \" + dev);","typeGuard":null,"tryCatchPattern":"try {\n  clusterer.doTraining();\n} catch (RuntimeException e) {\n  if (\"Error setting up training\".equals(e.getMessage()))\n    throw new IllegalStateException(\"Training setup failed, cause: \" + e.getCause(), e);\n  throw e;\n}","preventionTips":["Create and permission-check the output directory before long training runs","Verify dev/eval data files exist at the configured data path","Keep the models/dcoref data layout intact","Log e.getCause() to distinguish writer vs data-loading failures"],"tags":["java","corenlp","training","setup","io"],"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"}