{"record":{"id":"eff40e86e3285064","repo":"apache/beam","slug":"could-not-find-class-kafkaio","errorCode":null,"errorMessage":"Could not find class: ","messagePattern":"Could not find class: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaIO.java","lineNumber":4141,"sourceCode":"        }\n      } else if (!hasHeaders && row.getSchema().hasField(FIELD_HEADERS)) {\n        // Log warning when headers are present but Kafka client doesn't support them\n        LOG.warn(\n            \"Dropping headers from Kafka record because the Kafka client version \"\n                + \"does not support headers (requires Kafka 0.11+).\");\n      }\n\n      return hasHeaders\n          ? new ProducerRecord<>(topic, partition, timestamp, key, value, headers)\n          : new ProducerRecord<>(topic, partition, timestamp, key, value);\n    }\n  }\n\n  private static Class<?> resolveClass(String className) {\n    try {\n      return Class.forName(className);\n    } catch (ClassNotFoundException e) {\n      throw new RuntimeException(\"Could not find class: \" + className);\n    }\n  }\n}\n","sourceCodeStart":4123,"sourceCodeEnd":4145,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaIO.java#L4123-L4145","documentation":"resolveClass loads a deserializer/serializer/startup-modes class by name via Class.forName in the external transform configuration path. If the class is not on the classpath, the ClassNotFoundException is converted to this RuntimeException naming the class.","triggerScenarios":"Passing a keyDeserializer/valueDeserializer (or other class-name config field) whose class is not present at pipeline-construction time — typo in fully-qualified name, or the jar providing the class missing from the classpath.","commonSituations":"Using KafkaAvroDeserializer without the kafka-avro-serializer dependency; typos in class names; shaded/relocated class names after a version upgrade.","solutions":["Fix the fully-qualified class name (check package and spelling).","Add the dependency jar containing the class (e.g. io.confluent:kafka-avro-serializer) to the pipeline classpath.","Verify with Class.forName in a quick test or `mvn dependency:tree` that the artifact is included."],"exampleFix":"// before\n\"KafkaAvroDeserializer\"  // no package, not on classpath\n// after\n\"io.confluent.kafka.serializers.KafkaAvroDeserializer\" + add io.confluent:kafka-avro-serializer dependency","handlingStrategy":"validation","validationCode":"try {\n  Class.forName(deserializerName);\n} catch (ClassNotFoundException e) {\n  throw new IllegalArgumentException(\"Deserializer not on classpath: \" + deserializerName\n      + \". Add the providing dependency (e.g. io.confluent:kafka-avro-serializer).\", e);\n}","typeGuard":null,"tryCatchPattern":"try {\n  pipeline.apply(KafkaIO.readAllExternal(config));\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Could not find class:\")) {\n    log.error(\"Missing deserializer class; verify FQCN and dependencies: {}\", e.getMessage());\n  }\n  throw e;\n}","preventionTips":["Always use fully-qualified class names in deserializer config","Run mvn dependency:tree to confirm serialization dependencies are bundled","Class-load check in a startup unit test before launching pipelines"],"tags":["java","kafka","classpath","reflection"],"backgroundTag":"class-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}