stanfordnlp/CoreNLP · error · IllegalArgumentException

Directory access problem for

Error message

Directory access problem for: ${path}

What it means

When primeNextFile encounters a directory it calls File.listFiles(filt); a null return means the directory could not be read (I/O error, permissions, race deletion). The class surfaces this as IllegalArgumentException naming the offending path.

Solutions

  1. Verify the process has read+execute permission on the directory (ls -ld path; chmod/chown as needed).
  2. Confirm the directory exists and is a real directory before constructing the collection (path.isDirectory()).
  3. Check for external deletion or remounting; re-check mount status and logs.
  4. Run outside sandbox/SELinux/AppArmor restrictions or adjust policy to allow directory listing.

Example fix

// before
new FileSequentialCollection(files, filter, false); // files contains unreadable dir
// after
File dir = new File("/data/corpus");
if (!dir.isDirectory() || !dir.canRead()) throw new IllegalStateException("Unreadable dir: " + dir);
new FileSequentialCollection(files, filter, false);
Defensive patterns

Strategy: validation

Validate before calling

File dir = new File(path);
if (!dir.isDirectory() || !dir.canRead() || dir.listFiles() == null) {
  throw new IllegalStateException("Cannot list directory: " + dir);
}

Type guard

boolean isListableDir(File d) {
  return d.isDirectory() && d.canRead() && d.listFiles() != null;
}

Try / catch

try {
  for (File f : new FileSequentialCollection(seeds, filt, includeDirs)) { process(f); }
} catch (IllegalArgumentException e) {
  log.severe("Directory listing failed: " + e.getMessage());
}

Prevention

When it happens

Trigger: Iterating a FileSequentialCollection whose seed path is a directory that listFiles() cannot enumerate: unreadable directory, deleted between checks, or path is not actually a readable directory on that filesystem.

Common situations: Running without read/execute permission on a data directory; NFS mounts dropping; directory removed by another process during iteration; typos producing a pseudo-directory path; sandboxed/containers denying access.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/io/FileSequentialCollection.java:338

              // this directory is finished and we pop up
              fileArrayStack.pop();
            }
          } else {
            // take it off the stack: tail recursion optimization
            fileArrayStack.pop();
            if (obj instanceof String) {
              obj = new File((String) obj);
            }
            if (!(obj instanceof File)) {
              throw new IllegalArgumentException("Collection elements must be Files or Strings");
            }
            File path = (File) obj;
            if (path.isDirectory()) {
              // log.info("Got directory " + path);
              // if path is a directory, look into it
              File[] directoryListing = path.listFiles(filt);
              if (directoryListing == null) {
                throw new IllegalArgumentException("Directory access problem for: " + path);
              }
              // log.info("  with " +
              //	    directoryListing.length + " files in it.");
              if (includeDirs) {
                // log.info("Include dir as answer");
                if (directoryListing.length > 0) {
                  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

View on GitHub (pinned to 1b7edd19c4)