{"record":{"id":"a2c6249e0f2927c2","repo":"apache/hadoop","slug":"could-not-find-method-s-from-class-s-with-signat","errorCode":null,"errorMessage":"could not find method %s from class %s with signature %s\n","messagePattern":"could not find method (.+?) from class (.+?) with signature (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/jni_helper.c","lineNumber":310,"sourceCode":"\njthrowable methodIdFromClass(jclass cls, const char *className,\n        const char *methName, const char *methSignature, MethType methType,\n        JNIEnv *env, jmethodID *out)\n{\n    jthrowable jthr;\n    jmethodID mid = 0;\n\n    jthr = validateMethodType(env, methType);\n    if (jthr)\n        return jthr;\n    if (methType == STATIC) {\n        mid = (*env)->GetStaticMethodID(env, cls, methName, methSignature);\n    }\n    else if (methType == INSTANCE) {\n        mid = (*env)->GetMethodID(env, cls, methName, methSignature);\n    }\n    if (mid == NULL) {\n        fprintf(stderr, \"could not find method %s from class %s with \"\n            \"signature %s\\n\", methName, className, methSignature);\n        return getPendingExceptionAndClear(env);\n    }\n    *out = mid;\n    return NULL;\n}\n\njthrowable classNameOfObject(jobject jobj, JNIEnv *env, char **name)\n{\n    jthrowable jthr;\n    jclass cls, clsClass = NULL;\n    jmethodID mid;\n    jstring str = NULL;\n    const char *cstr = NULL;\n    char *newstr;\n\n    cls = (*env)->GetObjectClass(env, jobj);\n    if (cls == NULL) {","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/jni_helper.c#L292-L328","documentation":"jni_helper.c resolves and caches JNI method IDs via methodIdFromClass using GetMethodID/GetStaticMethodID. When the JVM cannot find the named method with that exact signature on the class, libhdfs prints this message and propagates the pending JVM exception (typically NoSuchMethodError). In practice this means the native library and the Hadoop jars on CLASSPATH come from different versions, or the classes were relocated by shading.","triggerScenarios":"libhdfs.so built against Hadoop X while CLASSPATH contains hadoop-common/hadoop-hdfs jars from Hadoop Y where the method was added, removed, renamed, or given a different signature; two versions of a jar on the CLASSPATH with the older one winning; shaded/relocated org.apache.hadoop classes.","commonSituations":"Embedding frameworks (Spark, Hive, Flink) shipping their own Hadoop jars while LD_LIBRARY_PATH points at the cluster's libhdfs.so; stale CLASSPATH environment variables; partial cluster upgrades.","solutions":["Set CLASSPATH from the same installation that provides libhdfs.so: eval \"$(hadoop classpath --glob)\"","Ensure exactly one version of hadoop-common and hadoop-hdfs client jars is reachable on the CLASSPATH","Replace or rebuild libhdfs.so so its version matches the jars","Restart the process after fixing the classpath, since cached class/method state lives as long as the JVM"],"exampleFix":"# before\nexport CLASSPATH=/opt/old-hadoop/share/hadoop/common/*:/opt/old-hadoop/share/hadoop/hdfs/*\n\n# after (single matching installation)\nexport HADOOP_HOME=/opt/hadoop-3.3.6\nexport LD_LIBRARY_PATH=$HADOOP_HOME/lib/native\nexport CLASSPATH=\"`$HADOOP_HOME/bin/hadoop classpath --glob`\"","handlingStrategy":"validation","validationCode":"/* fail fast at startup: environment must be coherent before any libhdfs call */\nstatic int check_hadoop_env(void) {\n    const char *cp = getenv(\"CLASSPATH\");\n    const char *lp = getenv(\"LD_LIBRARY_PATH\");\n    if (!cp || !*cp) return -1;          /* no classpath */\n    if (!lp || !strstr(lp, \"native\")) return -2;  /* libhdfs.so dir missing */\n    return 0;\n}\n\n/* plus smoke-test: */\n/* hdfsBuilderConnect + hdfsExists(fs, \"/\") — failure here means a JNI/classpath mismatch\n   caught at deploy time, not mid-job */","typeGuard":null,"tryCatchPattern":"hdfsFS fs = hdfsConnect(\"hdfs://nn:8020\", NULL);\nif (fs == NULL) {\n    /* EINTERNAL from getJNIEnv: inspect stderr for the methodIdFromClass message and\n       fix CLASSPATH/libhdfs version alignment; do not retry with the same env */\n}","preventionTips":["Generate CLASSPATH with `hadoop classpath --glob` from the installation that provides libhdfs.so","Keep LD_LIBRARY_PATH (libhdfs.so, libjvm.so) and CLASSPATH pinned in one versioned env script","Smoke-test one hdfsConnect/hdfsExists at startup so a JNI mismatch fails the deployment, not production traffic"],"tags":["hdfs","libhdfs","jni","classpath","version-mismatch","nosuchmethoderror"],"backgroundTag":"jni-method-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}