apache/hadoop · error

-EIO

-EIO

Error message

testRecursiveJvmMutex: getJNIEnv failed

What it means

Error "testRecursiveJvmMutex: getJNIEnv failed " thrown in apache/hadoop.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_threaded.c:402

        fprintf(stderr, "testLibHdfs: all threads succeeded.  SUCCESS.\n");
        return EXIT_SUCCESS;
    }
    fprintf(stderr, "testLibHdfs: some threads failed: [");
    for (i = 0; i < tlhNumThreads; i++) {
        if (ti[i].success != 0) {
            fprintf(stderr, "%s%d", sep, i);
            sep = ", ";
        }
    }
    fprintf(stderr, "].  FAILURE.\n");
    return EXIT_FAILURE;
}

int testRecursiveJvmMutex() {
    jthrowable jthr;
    JNIEnv *env = getJNIEnv();
    if (!env) {
        fprintf(stderr, "testRecursiveJvmMutex: getJNIEnv failed\n");
        return -EIO;
    }
    jthr = newRuntimeError(env, "Dummy error to print for testing");

    /* printExceptionAndFree() takes the jvmMutex within */
    mutexLock(&jvmMutex);
    printExceptionAndFree(env, jthr, PRINT_EXC_ALL, "testRecursiveJvmMutex");
    mutexUnlock(&jvmMutex);

    return 0;
}

/**
 * Test that we can write a file with libhdfs and then read it back
 */
int main(void)
{
    int i, tlhNumThreads;

View on GitHub (pinned to 2add963021)

Solutions

  1. Ensure the JVM was created with enough capacity for another thread attach (check globalJVM/JVM reference count in the test).
  2. Verify the current native thread is allowed to attach: JNIInvokeInterface must not have been destroyed mid-test.
  3. Check that hdfsThreadDomains/mutex initialization (hdfsThreadOnce) completed successfully before this test runs.

When it happens

Trigger: Raised in testRecursiveJvmMutex when getJNIEnv fails to obtain a JNI environment for the current thread.

Common situations: Occurs when the cached JVM reference is NULL or thread attach failed, typically because hdfsBuilderConnect was never called or the JVM was destroyed.


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/ee7f00f9d4dfd4f7. Report an issue: GitHub.