{"record":{"id":"978639ff3f9f250e","repo":"apache/beam","slug":"unable-to-construct-factoryfn-s-s","errorCode":null,"errorMessage":"Unable to construct FactoryFn %s: %s","messagePattern":"Unable to construct FactoryFn (.+?): (.+?)","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":977,"sourceCode":"        if (config.consumerFactoryFnClass != null) {\n          if (config.consumerFactoryFnClass.contains(\"KerberosConsumerFactoryFn\")) {\n            try {\n              if (!config.consumerFactoryFnParams.containsKey(\"krb5Location\")) {\n                throw new IllegalArgumentException(\n                    \"The KerberosConsumerFactoryFn requires a location for the krb5.conf file. \"\n                        + \"Please provide either a GCS location or Google Secret Manager location for this file.\");\n              }\n              String krb5Location = config.consumerFactoryFnParams.get(\"krb5Location\");\n              builder.setConsumerFactoryFn(\n                  InstanceBuilder.ofType(\n                          new TypeDescriptor<\n                              SerializableFunction<\n                                  Map<String, Object>, Consumer<byte[], byte[]>>>() {})\n                      .fromClassName(config.consumerFactoryFnClass)\n                      .withArg(String.class, Objects.requireNonNull(krb5Location))\n                      .build());\n            } catch (Exception e) {\n              throw new RuntimeException(\n                  \"Unable to construct FactoryFn \"\n                      + config.consumerFactoryFnClass\n                      + \": \"\n                      + e.getMessage(),\n                  e);\n            }\n          }\n        }\n      }\n\n      private static <T> Coder<T> resolveCoder(Class<Deserializer<T>> deserializer) {\n        for (Method method : deserializer.getDeclaredMethods()) {\n          if (method.getName().equals(\"deserialize\")) {\n            Class<?> returnType = method.getReturnType();\n            if (returnType.equals(Object.class)) {\n              continue;\n            }\n            if (returnType.equals(byte[].class)) {","sourceCodeStart":959,"sourceCodeEnd":995,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaIO.java#L959-L995","documentation":"setupExternalBuilder catches any exception while instantiating the configured consumer FactoryFn (e.g. KerberosConsumerFactoryFn via InstanceBuilder) and rethrows it as a RuntimeException with the class name and original message. It signals that the factory function class could not be constructed with the given parameters.","triggerScenarios":"The consumerFactoryFnClass cannot be loaded or instantiated: class not on classpath, constructor signature mismatch with the provided params, invalid krb5Location (download failure inside the factory), or any exception thrown by the factory's constructor.","commonSituations":"Typo in the fully-qualified class name; custom factory not staged with the job; wrong parameter types in consumerFactoryFnParams (e.g. non-String krb5Location); unreachable GCS/Secret Manager krb5.conf.","solutions":["Read the wrapped cause ('...: <message>') to find the root failure.","Verify consumerFactoryFnClass is the correct fully-qualified class name and is included in the job's classpath/staged files.","Check consumerFactoryFnParams types (krb5Location must be a String) and values (valid GCS/Secret Manager path).","Ensure credentials/permissions allow reading the krb5.conf location."],"exampleFix":"// before\n{\"consumerFactoryFnClass\": \"com.example.MyFactory\"} // not staged\n// after\n{\"consumerFactoryFnClass\": \"org.apache.beam.sdk.io.kafka.KerberosConsumerFactoryFn\", \"consumerFactoryFnParams\": {\"krb5Location\": \"gs://bucket/krb5.conf\"}}","handlingStrategy":"try-catch","validationCode":"Class.forName(config.consumerFactoryFnClass);","typeGuard":null,"tryCatchPattern":"try { build(cfg); } catch (RuntimeException e) { log(e.getCause()); }","preventionTips":["Stage factory classes; FQCN verbatim; typed params"],"tags":["kafka","reflection","factory","configuration","beam-io"],"backgroundTag":"module-init-failed","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"}