{"record":{"id":"441634815c1f6003","repo":"apache/hadoop","slug":"native-object-create-failed-class","errorCode":null,"errorMessage":"Native object create failed, class: {}","messagePattern":"Native object create failed, class: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/java/org/apache/hadoop/mapred/nativetask/NativeBatchProcessor.java","lineNumber":120,"sourceCode":"      this.rawInputBuffer = input.getByteBuffer();\n    }\n    if (null != output) {\n      this.out = output;\n      this.rawOutputBuffer = output.getByteBuffer();\n    }\n  }\n\n  @Override\n  public void setCommandDispatcher(CommandDispatcher handler) {\n    this.commandDispatcher = handler;\n  }\n\n  @Override\n  public void init(Configuration conf) throws IOException {\n    this.nativeHandlerAddr = NativeRuntime\n        .createNativeObject(nativeHandlerName);\n    if (this.nativeHandlerAddr == 0) {\n      throw new RuntimeException(\"Native object create failed, class: \"\n          + nativeHandlerName);\n    }\n    setupHandler(nativeHandlerAddr, ConfigUtil.toBytes(conf));\n  }\n\n  @Override\n  public synchronized void close() throws IOException {\n    if (nativeHandlerAddr != 0) {\n      NativeRuntime.releaseNativeObject(nativeHandlerAddr);\n      nativeHandlerAddr = 0;\n    }\n    IOUtils.cleanupWithLogger(LOG, in);\n    in = null;\n  }\n\n  @Override\n  public long getNativeHandler() {\n    return nativeHandlerAddr;","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/java/org/apache/hadoop/mapred/nativetask/NativeBatchProcessor.java#L102-L138","documentation":"NativeBatchProcessor.init calls NativeRuntime.createNativeObject(nativeHandlerName), a JNI call that returns a native pointer (0 on failure). A 0 return means the JNI library is loaded but the C++ side could not instantiate the named handler class - typically the handler name is not registered in libnativetask.so, or the .so was built against a different version than the jars. init throws RuntimeException to fail fast before any native data flows.","triggerScenarios":"The nativetask pipeline constructs a NativeBatchProcessor for a handler name unknown to the loaded libnativetask.so; or mixing Hadoop distribution jars with native libraries from another build; or developing a custom native platform whose handler name was never registered in the C++ factory.","commonSituations":"Replacing hadoop jars without updating lib/native; tarball installs where HADOOP_HOME points at mismatched native dirs; custom nativetask platform development where the Java-side handler name and the C++ REGISTER_HANDLER names drift.","solutions":["Run 'hadoop checknative' to verify libnativetask.so is found and matches the distribution","Ensure the jars and libnativetask.so come from the exact same Hadoop build (reinstall or re-extract the release tarball)","If building custom handlers, confirm the C++ factory registration name matches nativeHandlerName exactly and rebuild the native library","As a stopgap, disable the native path (revert mapreduce.job.map.output.collector.class to the default MapOutputBuffer) so jobs proceed on the Java path"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!NativeRuntime.isNativeLibraryLoaded()) {\n  conf.unset(\"mapreduce.job.map.output.collector.class\"); // Java fallback path\n} else {\n  // native path OK; handler must still be registered in the loaded libnativetask.so\n}","typeGuard":null,"tryCatchPattern":"try {\n  processor.init(conf);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Native object create failed\")) {\n    // handler not registered in this native build: realign jars/so or disable native path\n    throw new IllegalStateException(\"Native handler unavailable; align native libs or disable nativetask\", e);\n  }\n  throw e;\n}","preventionTips":["Keep Hadoop jars and lib/native from the same release tarball","Run 'hadoop checknative' as a deployment smoke test on every node","In custom platforms, add unit tests asserting createNativeObject returns non-zero for every registered handler name"],"tags":["native","jni","nativetask","environment","version-mismatch"],"backgroundTag":"native-library-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}