stanfordnlp/CoreNLP · error · RuntimeException
File problem
Error message
File problem: <e>
What it means
QPTreeTransformer.main loads trees from files given on the command line using PennTreeReader; any IOException while opening or reading those files is wrapped in this bare RuntimeException("File problem: " + e), typically meaning the named tree file does not exist or cannot be read.
Solutions
- Verify the file path passed on the command line exists and is readable (ls -l <path>), fixing the path or running from the correct directory.
- Use absolute paths or paths relative to the actual working directory when invoking the tool.
- Check file permissions; chmod/read-access the tree file if needed.
- Catch the RuntimeException in a wrapper script and validate files exist before invoking the tool.
Example fix
// before java edu.stanford.nlp.trees.QPTreeTransformer wsj/0001/wsj_0101.mrg // wrong cwd // after java edu.stanford.nlp.trees.QPTreeTransformer "/data/ptb/wsj/00/wsj_0101.mrg" // verified existing absolute path
Defensive patterns
Strategy: validation
Validate before calling
List<String> files = Arrays.asList(treeFileNames);
for (String name : files) {
File f = new File(name);
if (!f.isFile() || !f.canRead())
throw new IllegalArgumentException("Tree file not readable: " + f.getAbsolutePath());
} Try / catch
try {
QPTreeTransformer.main(args);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("File problem:")) {
log.error("Bad tree file argument: " + e.getMessage());
} else throw e;
} Prevention
- Use absolute paths when invoking CLI tree tools from scripts or other directories.
- Check existence/read permission of every argument file before running the tool.
- Avoid spaces/typos in paths by building argument lists programmatically from directory scans.
When it happens
Trigger: Running QPTreeTransformer.main with a treeFileName argument that points to a nonexistent file, a directory, or a file without read permission, so new FileInputStream(...) throws FileNotFoundException/IOException.
Common situations: Typos in the path on the command line; running from a different working directory than expected; files moved after a corpus reorganization; missing read permissions.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Cannot find or open + sentFileName
- e
- Error creating ChineseMaxentLexicon
- Could not read from double initial LOP weights file
- Couldn't read RegexNER from " + mapping
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/b89be1aff311f468.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/trees/QPTreeTransformer.java:168
}
public static void main(String[] args) {
QPTreeTransformer transformer = new QPTreeTransformer();
Treebank tb = new MemoryTreebank();
Properties props = StringUtils.argsToProperties(args);
String treeFileName = props.getProperty("treeFile");
if (treeFileName != null) {
try {
TreeReader tr = new PennTreeReader(new BufferedReader(new InputStreamReader(new FileInputStream(treeFileName))), new LabeledScoredTreeFactory());
Tree t;
while ((t = tr.readTree()) != null) {
tb.add(t);
}
} catch (IOException e) {
throw new RuntimeException("File problem: " + e);
}
}
for (Tree t : tb) {
System.out.println("Original tree");
t.pennPrint();
System.out.println();
System.out.println("Tree transformed");
Tree tree = transformer.transformTree(t);
tree.pennPrint();
System.out.println();
System.out.println("----------------------------");
}
}
}
View on GitHub (pinned to 1b7edd19c4)