apache/hadoop · error
EIO
EIO
Error message
hdfsGetWorkingDirectory: FileSystem#getWorkingDirectory returned NULL
What it means
hdfsGetWorkingDirectory calls FileSystem#getWorkingDirectory over JNI. The Java contract says this never returns null (it falls back to the working/home directory), so a null Path means a broken or custom FileSystem implementation or corrupted JVM state; libhdfs prints the message and fails with ret = -EIO.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/hdfs.c:2918
//Get the JNIEnv* corresponding to current thread
JNIEnv* env = getJNIEnv();
if (env == NULL) {
errno = EINTERNAL;
return NULL;
}
//FileSystem#getWorkingDirectory()
jthr = invokeMethod(env, &jVal, INSTANCE, jFS, JC_FILE_SYSTEM,
"getWorkingDirectory", "()Lorg/apache/hadoop/fs/Path;");
if (jthr) {
ret = printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
"hdfsGetWorkingDirectory: FileSystem#getWorkingDirectory");
goto done;
}
jPath = jVal.l;
if (!jPath) {
fprintf(stderr, "hdfsGetWorkingDirectory: "
"FileSystem#getWorkingDirectory returned NULL");
ret = -EIO;
goto done;
}
//Path#toString()
jthr = invokeMethod(env, &jVal, INSTANCE, jPath, JC_PATH, "toString",
"()Ljava/lang/String;");
if (jthr) {
ret = printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
"hdfsGetWorkingDirectory: Path#toString");
goto done;
}
jPathString = jVal.l;
jPathChars = (*env)->GetStringUTFChars(env, jPathString, NULL);
if (!jPathChars) {
ret = printPendingExceptionAndFree(env, PRINT_EXC_ALL,
"hdfsGetWorkingDirectory: GetStringUTFChars");View on GitHub (pinned to 2add963021)
Solutions
- Verify fs is a plain HDFS connection (hdfsConnect with an hdfs:// URI) and not a custom fs implementation
- Check the hadoop jars on CLASSPATH match the native library version
- Fall back to the conventional default working directory '/user/<user>' when the call fails with EIO
Defensive patterns
Strategy: fallback
Try / catch
errno = 0;
if (hdfsGetWorkingDirectory(fs, buf, sizeof(buf)) == NULL) {
/* EIO: JVM returned null Path; fall back to the conventional default */
snprintf(buf, sizeof(buf), "/user/%s", getpwuid(getuid())->pw_name);
} Prevention
- Use plain hdfs:// connections rather than custom FileSystem implementations
- Keep hadoop jar versions aligned with the native library
When it happens
Trigger: A custom or mocked FileSystem registered in the loaded configuration whose getWorkingDirectory returns null; a JVM left in a bad state by earlier pending exceptions that were swallowed.
Common situations: Test harnesses registering stub FileSystem implementations; third-party filesystem connectors on the classpath overriding the method; version-mismatched hadoop jars changing behavior.
Related errors
- EINTERNAL
- could not find method %s from class %s with signature %s
- JNI_GetCreatedJavaVMs failed with error: %d
- NativeIO is not available.
- PrintExceptionAndFree: error determining class name of excep
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/c56686e13b3b8d46.
Report an issue: GitHub.