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

  1. Check new File(path).exists() for every seed file before building the collection.
  2. Use absolute paths or resolve relative paths against an explicit base directory.
  3. Re-create/re-download the missing file or fix the path in configuration.
  4. 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

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


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)