stanfordnlp/CoreNLP · error · IllegalArgumentException
File doesn't exist
Error message
File doesn't exist: ${path} What it means
For a non-directory seed element, FileSequentialCollection returns the file directly but first checks path.exists(). If the file is missing it throws IllegalArgumentException with the path. This is a fail-fast guard against nonexistent plain files.
Solutions
- Check new File(path).exists() for every seed file before building the collection.
- Use absolute paths or resolve relative paths against an explicit base directory.
- Re-create/re-download the missing file or fix the path in configuration.
- Verify the file wasn't deleted by a prior pipeline step (check cleanup scripts).
Example fix
// before
new FileSequentialCollection(Arrays.asList("corpus/train.txt"));
// after
File f = new File("corpus/train.txt");
if (!f.exists()) throw new FileNotFoundException(f.getAbsolutePath());
new FileSequentialCollection(Collections.singletonList(f)); Defensive patterns
Strategy: validation
Validate before calling
File f = new File(path);
if (!f.exists()) {
throw new FileNotFoundException(f.getAbsolutePath());
} Try / catch
try {
for (File f : new FileSequentialCollection(seeds, filt, includeDirs)) { process(f); }
} catch (IllegalArgumentException e) {
log.severe("Missing file: " + e.getMessage());
} Prevention
- Call .getAbsoluteFile() and log paths before use
- Check exists() for each seed file up front
- Ensure producing pipeline stages finish before consumption
When it happens
Trigger: Constructing/iterating a FileSequentialCollection with a seed file path that does not exist on disk (typo, wrong working directory, file deleted before iteration).
Common situations: Relative paths resolved against an unexpected CWD; datasets downloaded later than expected; files cleaned by a job; configuration pointing at a machine-specific location.
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
- Output path does not exist
- can't open file
- Cannot find or open + sentFileName
- Cannot initialize logger!
- Collection elements must be Files or Strings
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/df020255d279192e.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/io/FileSequentialCollection.java:363
fileArrayStack.push(directoryListing);
fileArrayStackIndices.push(Integer.valueOf(0));
}
return path;
} else {
// we don't include the dir, so we'll push
// the directory and loop around again ...
if (directoryListing.length > 0) {
fileArrayStack.push(directoryListing);
fileArrayStackIndices.push(Integer.valueOf(0));
}
// otherwise there was nothing in the
// directory; we will pop back up
}
} else {
// it's just a fixed file
// log.info("Got a plain file " + path);
if (!path.exists()) {
throw new IllegalArgumentException("File doesn't exist: " + path);
}
return path;
}
}
// go through loop again. we've pushed or popped as needed
}
// finished this root entry; go on to the next
rootsIndex++;
if (rootsIndex < roots.length) {
fileArrayStack.add(roots[rootsIndex]);
fileArrayStackIndices.push(Integer.valueOf(0));
}
}
// finished everything
return null;
}
}View on GitHub (pinned to 1b7edd19c4)