{"record":{"id":"2c87d4cd31c639a9","repo":"apache/hadoop","slug":"key-type-not-supported-cannot-find-serializer-for","errorCode":null,"errorMessage":"Key type not supported. Cannot find serializer for {}","messagePattern":"Key type not supported\\. Cannot find serializer for (.+?)","errorType":"exception","errorClass":"InvalidJobConfException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/java/org/apache/hadoop/mapred/nativetask/NativeMapOutputCollectorDelegator.java","lineNumber":117,"sourceCode":"        job.get(Constants.MAP_SORT_CLASS);\n      LOG.error(message);\n      throw new InvalidJobConfException(message);\n    }\n\n    if (job.getBoolean(MRConfig.SHUFFLE_SSL_ENABLED_KEY, false) == true) {\n      String message = \"Native-Task doesn't support secure shuffle\";\n      LOG.error(message);\n      throw new InvalidJobConfException(message);\n    }\n\n    final Class<?> keyCls = job.getMapOutputKeyClass();\n    try {\n      @SuppressWarnings(\"rawtypes\")\n      final INativeSerializer serializer = NativeSerialization.getInstance().getSerializer(keyCls);\n      if (null == serializer) {\n        String message = \"Key type not supported. Cannot find serializer for \" + keyCls.getName();\n        LOG.error(message);\n        throw new InvalidJobConfException(message);\n      } else if (!Platforms.support(keyCls.getName(), serializer, job)) {\n        String message = \"Native output collector doesn't support this key, \" +\n          \"this key is not comparable in native: \" + keyCls.getName();\n        LOG.error(message);\n        throw new InvalidJobConfException(message);\n      }\n    } catch (final IOException e) {\n      String message = \"Cannot find serializer for \" + keyCls.getName();\n      LOG.error(message);\n      throw new IOException(message);\n    }\n\n    final boolean ret = NativeRuntime.isNativeLibraryLoaded();\n    if (ret) {\n      if (job.getBoolean(MRJobConfig.MAP_OUTPUT_COMPRESS, false)) {\n        String codec = job.get(MRJobConfig.MAP_OUTPUT_COMPRESS_CODEC);\n        if (!NativeRuntime.supportsCompressionCodec(codec.getBytes(StandardCharsets.UTF_8))) {\n          String message = \"Native output collector doesn't support compression codec \" + codec;","sourceCodeStart":99,"sourceCodeEnd":135,"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/NativeMapOutputCollectorDelegator.java#L99-L135","documentation":"The native collector serializes map-output keys with native code, so the map output key class must have a registered INativeSerializer. init calls NativeSerialization.getInstance().getSerializer(keyCls); a null return (no serializer factory registered for that class) produces InvalidJobConfException('Key type not supported. Cannot find serializer for <class>'). Out of the box, native serializers exist for the standard Writable key types (Text, IntWritable, LongWritable, FloatWritable, DoubleWritable, BytesWritable) plus whatever platforms add.","triggerScenarios":"Setting mapreduce.map.output.key.class (or job.setMapOutputKeyClass) to a custom or non-standard Writable while the native collector is enabled; getSerializer finds no factory for the class and returns null.","commonSituations":"Jobs with domain-specific composite key Writables moved onto a native-enabled cluster; using Avro/Protobuf-based key wrappers, or third-party Writable types, as the map output key.","solutions":["Use a natively supported key type (Text, IntWritable, LongWritable, FloatWritable, DoubleWritable, BytesWritable) as the map output key","Implement and register a custom INativeSerializer via a nativetask platform for your key class (NativeSerialization.register)","Disable the native collector for this job by unsetting mapreduce.job.map.output.collector.class"],"exampleFix":"// before\njob.setMapOutputKeyClass(MyCompositeKey.class); // custom Writable\nconf.set(\"mapreduce.job.map.output.collector.class\",\n    \"org.apache.hadoop.mapred.nativetask.NativeMapOutputCollectorDelegator\");\n\n// after\njob.setMapOutputKeyClass(Text.class); // serialize composite key as delimited Text","handlingStrategy":"validation","validationCode":"Class<?> keyCls = job.getMapOutputKeyClass();\nboolean nativeCollector = \"org.apache.hadoop.mapred.nativetask.NativeMapOutputCollectorDelegator\"\n    .equals(jobConf.get(\"mapreduce.job.map.output.collector.class\"));\nif (nativeCollector\n    && NativeSerialization.getInstance().getSerializer(keyCls) == null) {\n  jobConf.unset(\"mapreduce.job.map.output.collector.class\"); // no native serializer for this key\n}","typeGuard":null,"tryCatchPattern":"try {\n  collector.init(context);\n} catch (InvalidJobConfException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Key type not supported\")) {\n    // switch map output key to a natively supported Writable, or disable native collector\n  }\n  throw e;\n}","preventionTips":["Restrict map output keys to Text/IntWritable/LongWritable/FloatWritable/DoubleWritable/BytesWritable when nativetask is enabled","For custom keys, register an INativeSerializer via a platform before enabling the collector","Add a submit-time validator that queries NativeSerialization for the configured key class"],"tags":["nativetask","serialization","writable","job-configuration"],"backgroundTag":"unsupported-key-serialization","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}