apache/hadoop · error · FileNotFoundException
absolutePath + ": No such file or directory."
Error message
absolutePath + ": No such file or directory."
What it means
TypedBytesOutput.write(Object) serializes a Java object by runtime instanceof dispatch: Byte through String, ArrayList as VECTOR, any List as LIST, and Map as MAP are supported; everything else falls into the final else and throws RuntimeException 'cannot write objects of this type'. The library throws it because typed bytes has no wire code for the object's type, so writing it would corrupt the stream.
Source
Thrown at hadoop-cloud-storage-project/hadoop-bos/src/main/java/org/apache/hadoop/fs/bos/BaiduBosFileSystem.java:329
Path absolutePath = makeAbsolute(f);
String key = pathToKey(absolutePath);
if (key.isEmpty()) {
return newDirectory(null, absolutePath);
}
try {
FileMetadata meta = store.retrieveMetadata(key);
if (meta != null) {
if (meta.isFolder()) {
return meta.getLastModified() == 0
? newDirectory(null, absolutePath)
: newDirectory(meta, absolutePath);
} else {
return newFile(meta, absolutePath);
}
}
} catch (FileNotFoundException e) {
throw new FileNotFoundException(
absolutePath + ": No such file or directory.");
} catch (IOException e) {
LOG.error("bos-fs getFileStatus error: ", e);
throw e;
}
throw new FileNotFoundException(
absolutePath + ": No such file or directory.");
}
@Override
public FileChecksum getFileChecksum(Path f, long length)
throws IOException {
LOG.debug("call the checksum for the path: {}",
f.getName());
Path absolutePath = makeAbsolute(f);
String key = pathToKey(absolutePath);
return this.store.getFileChecksum(key);
}View on GitHub (pinned to 2add963021)
Solutions
- Convert before writing: POJO -> String (writeString), binary -> byte[] passed to writeBytes, numbers -> supported boxed types, sequences -> ArrayList/HashMap.
- If you need arbitrary Hadoop Writable objects, use the WRITABLE code path (writeWritable) instead of write(Object).
- For custom classes, serialize to bytes yourself and emit with the application-specific code range via writeBytes (codes 50-200).
- Add a pre-submit unit test that round-trips every object type your job writes through TypedBytesOutput/TypedBytesInput.
Example fix
// before
tOut.write(myPojo); // RuntimeException: unsupported type
tOut.write(new String[]{"a","b"}); // arrays unsupported
// after
tOut.writeString(myPojo.toString());
java.util.List<String> l = java.util.Arrays.asList("a","b");
tOut.write(new java.util.ArrayList<>(l)); // ArrayList -> VECTOR Defensive patterns
Strategy: type-guard
Type guard
static boolean typedBytesWritable(Object o) {
return o == null
|| o instanceof Byte || o instanceof Boolean || o instanceof Integer
|| o instanceof Long || o instanceof Short && false // Short unsupported
|| o instanceof Float || o instanceof Double
|| o instanceof String || o instanceof byte[] == false // byte[] NOT supported by write()
|| o instanceof ArrayList || o instanceof List || o instanceof Map;
} Try / catch
try {
tOut.write(obj);
} catch (RuntimeException e) {
if ("cannot write objects of this type".equals(e.getMessage())) {
tOut.writeString(String.valueOf(obj)); // safe fallback encoding
} else throw e;
} Prevention
- Convert POJOs/arrays/sets to String, byte[]-via-writeBytes, ArrayList or HashMap before write().
- Use writeWritable() for arbitrary Writable objects.
- Round-trip unit test every emitted type through TypedBytesOutput/TypedBytesInput.
When it happens
Trigger: Passing objects outside the supported set to write(), or to a writer layered on it (typed-bytes streaming output, TypedBytesRecordWriter): e.g. java.util.Date, custom POJOs, arrays (String[]/byte[] as Object), BigDecimal, LinkedList/HashMap are fine (List/Map) but Set, Object[] and boxed short are not.
Common situations: Streaming mapper/reducer scripts (Python/Ruby) emitting values that get boxed into unsupported types; Java code copying arbitrary Writables through typed bytes; upgrading a pipeline from text keys to complex Java objects without converting them first.
Related errors
- parent + " is a file"
- Parent directory doesn't exist: " + parent
- Exception while get content summary
- absolutePath + " is a file"
- f.toString()
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/64c81143003cd018.
Report an issue: GitHub.