{"record":{"id":"283cf0a899ee5303","repo":"stanfordnlp/CoreNLP","slug":"runtimeexception-with-no-message-model-write-fail","errorCode":null,"errorMessage":"RuntimeException with no message (model write failure)","messagePattern":"RuntimeException with no message \\(model write failure\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/coref/statistical/Clusterer.java","lineNumber":115,"sourceCode":"\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\n      examples = examples.subList(Math.max(0, examples.size()\n          - BUFFER_SIZE_MULTIPLIER * trainDocs.size()), examples.size());\n      trainPolicy(examples);\n\n      if (iteration % EVAL_FREQUENCY == 0) {\n        double trainScore = evaluatePolicy(trainDocs, true);\n        if (trainScore > bestTrainScore) {\n          bestTrainScore = trainScore;\n          writeModel(\"best\", outputPath);\n        }\n\n        if (iteration % 10 == 0) {\n          writeModel(\"iter_\" + iteration, outputPath);","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/coref/statistical/Clusterer.java#L97-L133","documentation":"In Clusterer.doTraining, after training finishes, writing the model weights and human-readable weight vector is wrapped in a bare `throw new RuntimeException()` with no message or cause. It means serializing/printing the trained clusterer model failed after training completed — the trained model is not persisted.","triggerScenarios":"classifier.writeWeights(outputPath + \"model\") or printWeightVector(IOUtils.getPrintWriter(...)) throws (IOException) because outputPath is missing/unwritable or the write fails mid-stream.","commonSituations":"Output directory deleted between training start and model write; disk full after a long training run; permissions changed; path too long.","solutions":["Ensure outputPath exists and is writable before launching training","Free disk space — long training runs can exhaust space exactly at the final model write","Check file permissions on the output directory","If you control the code, rethrow with message and cause: new RuntimeException(\"Error writing clusterer model\", e)"],"exampleFix":"// before\n} catch (Exception e) {\n  throw new RuntimeException();\n}\n// after\n} catch (Exception e) {\n  throw new RuntimeException(\"Error writing clusterer model\", e);\n}","handlingStrategy":"try-catch","validationCode":"java.io.File out = new java.io.File(outputPath);\nif (!out.isDirectory() || !out.canWrite())\n  throw new IllegalStateException(\"Model output dir missing/unwritable: \" + outputPath);\nif (out.getFreeSpace() < minRequiredBytes)\n  throw new IllegalStateException(\"Insufficient disk space for model write\");","typeGuard":null,"tryCatchPattern":"try {\n  clusterer.doTraining();\n} catch (RuntimeException e) {\n  if (e.getMessage() == null || e.getMessage().isEmpty())\n    log.error(\"Bare RuntimeException from Clusterer — likely model write failure\", e);\n  else throw e;\n}","preventionTips":["Ensure outputPath exists and is writable before training starts","Free disk space — model writes happen at the very end of long runs","Avoid concurrent jobs writing to the same output directory","Report upstream: ask library to rethrow with message+cause"],"tags":["java","corenlp","model-persistence","file-write"],"backgroundTag":"file-write-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"}