stanfordnlp/CoreNLP · error · edu.stanford.nlp.io.RuntimeIOException
Caught IOException outputting QN data to file
Error message
Caught IOException outputting QN data to file
What it means
When QNMinimizer is configured to write output to files (outFile/infoFile), any IOException while opening or writing these files is wrapped in RuntimeIOException so it escapes as an unchecked exception. It signals failure to create the diagnostic/output files, not a problem with the optimization itself.
Solutions
- Ensure the output directory exists and is writable before calling minimize().
- Catch RuntimeIOException around minimize() and handle/log it.
- Disable or relocate file output if it is not needed.
Example fix
// before
File dir = new File("/logs/qn");
minimizer.minimize(f, tol, init); // RuntimeIOException if /logs/qn missing
// after
File dir = new File("/logs/qn");
dir.mkdirs();
minimizer.setOutputFile(new File(dir, "qn-out"));
minimizer.minimize(f, tol, init); Defensive patterns
Strategy: validation
Validate before calling
File outDir = new File(baseName).getAbsoluteFile().getParentFile();
if (outDir == null || !outDir.isDirectory() || !outDir.canWrite())
throw new IllegalStateException("QN output directory not writable: " + outDir); Try / catch
try {
minimizer.minimize(f, tol, init);
} catch (RuntimeIOException e) {
log.severe("QN output IO failed: " + e.getMessage());
// retry without file output or with a new directory
} Prevention
- Create the output directory (mkdirs) before training.
- Verify canWrite() on the target path.
- Avoid output paths on network shares or read-only containers.
- Give each run a unique baseName to avoid file locks.
When it happens
Trigger: Calling minimize() with output writing enabled (e.g. QNMinimizer set to dump function/gradient info) when the base output path is unwritable, the directory does not exist, disk is full, or a FileOutputStream to baseName + ".txt"/".info" fails.
Common situations: Running training on a read-only filesystem, a nonexistent output directory, insufficient write permissions, or reusing a path that is locked by another process.
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
- Cannot initialize logger!
- Could not create output stream (cannot write file): " +…
- Error creating data exporter
- Error opening output file
- Exception: in printToFile
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/22ecc6449103b355.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/optimization/QNMinimizer.java:934
} else {
grad = rawGrad;
}
PrintWriter outFile = null;
PrintWriter infoFile = null;
if (outputToFile) {
try {
String baseName = "QN_m" + mem + '_' + lsOpt.toString() + '_'
+ scaleOpt.toString();
outFile = new PrintWriter(new FileOutputStream(baseName + ".output"),
true);
infoFile = new PrintWriter(new FileOutputStream(baseName + ".info"),
true);
infoFile.println(dFunction.domainDimension() + "; DomainDimension ");
infoFile.println(mem + "; memory");
} catch (IOException e) {
throw new RuntimeIOException("Caught IOException outputting QN data to file", e);
}
}
Record rec = new Record(monitor, functionTolerance, outFile);
// sets the original gradient and x. Also stores the monitor.
rec.start(value, rawGrad, x);
// Check if max Evaluations and Iterations have been provided.
maxFevals = (maxFunctionEvaluations > 0) ? maxFunctionEvaluations
: Integer.MAX_VALUE;
// maxIterations = (maxIterations > 0) ? maxIterations : Integer.MAX_VALUE;
if (!quiet) {
log.info(" An explanation of the output:");
log.info("Iter The number of iterations");
log.info("evals The number of function evaluations");
log.info("SCALING <D> Diagonal scaling was used; <I> Scaled Identity");
log.info("LINESEARCH [## M steplength] Minpack linesearch");View on GitHub (pinned to 1b7edd19c4)