apache/hadoop · error · FileNotFoundException
File {} not found in {}
Error message
File {} not found in {} What it means
listStatus looks the path up directly in the archive index (metadata.archive.get(harPath) at HarFileSystem.java:793); when no entry exists it throws FileNotFoundException. Unlike getFileStatus, there is no separate invalid-name check — any path that does not resolve to an index entry (wrong name, or a path the archive does not contain) lands here.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java:795
throw new IOException("Har: delete not allowed");
}
/**
* liststatus returns the children of a directory
* after looking up the index files.
*/
@Override
public FileStatus[] listStatus(Path f) throws IOException {
//need to see if the file is an index in file
//get the filestatus of the archive directory
// we will create fake filestatuses to return
// to the client
List<FileStatus> statuses = new ArrayList<FileStatus>();
Path tmpPath = makeQualified(f);
Path harPath = getPathInHar(tmpPath);
HarStatus hstatus = metadata.archive.get(harPath);
if (hstatus == null) {
throw new FileNotFoundException("File " + f + " not found in " + archivePath);
}
if (hstatus.isDir()) {
fileStatusesInIndex(hstatus, statuses);
} else {
statuses.add(toFileStatus(hstatus));
}
return statuses.toArray(new FileStatus[statuses.size()]);
}
/**
* return the top level archive path.
*/
@Override
public Path getHomeDirectory() {
return new Path(uri.toString());
}
View on GitHub (pinned to 2add963021)
Solutions
- List the parent directory (or the archive root) to see which entries actually exist in the index
- If the directory was added after archiving, rebuild with `hadoop archive`
- Confirm the path is under the same .har directory as the filesystem's own URI
Example fix
// before
fs.listStatus(new Path("har://hdfs-nn:8020/a/data.har/reportts")); // typo
// after
fs.listStatus(new Path("har://hdfs-nn:8020/a/data.har")); // list archive root, then drill down by exact names Defensive patterns
Strategy: try-catch
Validate before calling
Path parent = p.getParent();
try {
FileStatus[] children = fs.listStatus(parent);
boolean exists = java.util.Arrays.stream(children).anyMatch(s -> s.getPath().getName().equals(p.getName()));
} catch (FileNotFoundException e) { /* parent itself is not in the index */ } Try / catch
try {
FileStatus[] st = fs.listStatus(p);
} catch (FileNotFoundException e) {
// no index entry for p: list the parent or the archive root to discover real names
} Prevention
- Treat FileNotFoundException from listStatus as the supported not-found signal
- Discover member names by listing top-down from the archive root instead of guessing
- Rebuild archives when source directories change so listings match expectations
When it happens
Trigger: fs.listStatus(p) where p is not an index entry: a misspelled member or directory, a path 'inside' the archive directory that was never archived, or a path outside this archive's namespace whose har-relative lookup misses.
Common situations: Directory-listing UIs and globbing over archived datasets; consumers listing a sub-directory that exists in the source tree but was added after the archive was built; typos in stored path templates.
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
- File: {} does not exist in {}
- {} : not a file in {}
- File " + f + " does not exist
- key + ": No such file or directory."
- No such file or directory '{}'
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/467f5bfe5bf9e841.
Report an issue: GitHub.