stanfordnlp/CoreNLP · error · RuntimeException

RuntimeException with no message (model write failure)

Error message

RuntimeException with no message (model write failure)

What it means

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.

Solutions

  1. Ensure outputPath exists and is writable before launching training
  2. Free disk space — long training runs can exhaust space exactly at the final model write
  3. Check file permissions on the output directory
  4. If you control the code, rethrow with message and cause: new RuntimeException("Error writing clusterer model", e)

Example fix

// before
} catch (Exception e) {
  throw new RuntimeException();
}
// after
} catch (Exception e) {
  throw new RuntimeException("Error writing clusterer model", e);
}
Defensive patterns

Strategy: try-catch

Validate before calling

java.io.File out = new java.io.File(outputPath);
if (!out.isDirectory() || !out.canWrite())
  throw new IllegalStateException("Model output dir missing/unwritable: " + outputPath);
if (out.getFreeSpace() < minRequiredBytes)
  throw new IllegalStateException("Insufficient disk space for model write");

Try / catch

try {
  clusterer.doTraining();
} catch (RuntimeException e) {
  if (e.getMessage() == null || e.getMessage().isEmpty())
    log.error("Bare RuntimeException from Clusterer — likely model write failure", e);
  else throw e;
}

Prevention

When it happens

Trigger: classifier.writeWeights(outputPath + "model") or printWeightVector(IOUtils.getPrintWriter(...)) throws (IOException) because outputPath is missing/unwritable or the write fails mid-stream.

Common situations: Output directory deleted between training start and model write; disk full after a long training run; permissions changed; path too long.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/coref/statistical/Clusterer.java:115

      Redwood.log("scoref.train", "Loading training data");
      StatisticalCorefTrainer.setDataPath("dev");
      trainDocs = ClustererDataLoader.loadDocuments(MAX_DOCS);
    } catch (Exception e) {
      throw new RuntimeException("Error setting up training", e);
    }

    double bestTrainScore = 0;
    List<List<Pair<CandidateAction, CandidateAction>>> examples = new ArrayList<>();
    for (int iteration = 0; iteration < RETRAIN_ITERATIONS; iteration++) {
      Redwood.log("scoref.train", "ITERATION " + iteration);
      classifier.printWeightVector(null);
      Redwood.log("scoref.train", "");
      try {
        classifier.writeWeights(outputPath + "model");
        classifier.printWeightVector(IOUtils.getPrintWriter(outputPath + "weights"));
      } catch (Exception e) {
        throw new RuntimeException();
      }

      long start = System.currentTimeMillis();
      Collections.shuffle(trainDocs, random);

      examples = examples.subList(Math.max(0, examples.size()
          - BUFFER_SIZE_MULTIPLIER * trainDocs.size()), examples.size());
      trainPolicy(examples);

      if (iteration % EVAL_FREQUENCY == 0) {
        double trainScore = evaluatePolicy(trainDocs, true);
        if (trainScore > bestTrainScore) {
          bestTrainScore = trainScore;
          writeModel("best", outputPath);
        }

        if (iteration % 10 == 0) {
          writeModel("iter_" + iteration, outputPath);

View on GitHub (pinned to 1b7edd19c4)