{"record":{"id":"932b45c0f1ab5afe","repo":"apache/beam","slug":"unable-to-generate-a-creator-for-class-with-schema-pojoutils","errorCode":null,"errorMessage":"Unable to generate a creator for class {} with schema {}","messagePattern":"Unable to generate a creator for class (.+?) with schema (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/POJOUtils.java","lineNumber":279,"sourceCode":"              .with(new InjectPackageStrategy(clazz))\n              .subclass(SchemaUserTypeCreator.class)\n              .method(ElementMatchers.named(\"create\"))\n              .intercept(\n                  new StaticFactoryMethodInstruction(\n                      types, clazz, creator, typeConversionsFactory));\n\n      return builder\n          .visit(new AsmVisitorWrapper.ForDeclaredMethods().writerFlags(ClassWriter.COMPUTE_FRAMES))\n          .make()\n          .load(ReflectHelpers.findClassLoader(), getClassLoadingStrategy(clazz))\n          .getLoaded()\n          .getDeclaredConstructor()\n          .newInstance();\n    } catch (InstantiationException\n        | IllegalAccessException\n        | NoSuchMethodException\n        | InvocationTargetException e) {\n      throw new RuntimeException(\n          \"Unable to generate a creator for class \" + clazz + \" with schema \" + schema);\n    }\n  }\n\n  /**\n   * Generate the following {@link FieldValueSetter} class for the {@link Field}.\n   *\n   * <pre><code>\n   *   class Getter implements {@literal FieldValueGetter<POJO, FieldType>} {\n   *     {@literal @}Override public String name() { return field.getName(); }\n   *     {@literal @}Override public Class type() { return field.getType(); }\n   *     {@literal @}Override public FieldType get(POJO pojo) {\n   *        return convert(pojo.field);\n   *      }\n   *   }\n   * </code></pre>\n   */\n  static <ObjectT, ValueT> FieldValueGetter<@NonNull ObjectT, ValueT> createGetter(","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/POJOUtils.java#L261-L297","documentation":"createStaticCreator builds a creator around a class's declared zero-argument constructor and throws this RuntimeException when instantiation fails, for the same reflective reasons as error 384. It is invoked from getStaticCreator for types that were determined to use a static/zero-arg creation path.","triggerScenarios":"getStaticCreator -> createStaticCreator on a class whose getDeclaredConstructor() finds no zero-arg constructor, or whose constructor is inaccessible, or the class is abstract/interface, or the constructor throws.","commonSituations":"Registry/configured class names that don't match the expected POJO shape, refactored classes losing their no-arg constructor, or classes instantiated reflectively at runtime on a different classloader.","solutions":["Ensure the class has a public zero-argument constructor.","Annotate a factory method with @SchemaCreate if zero-arg construction isn't valid for the type.","Verify the class name/type registered in the pipeline matches a concrete instantiable class.","Reproduce the reflective call manually to surface the real cause (InstantiationException vs NoSuchMethodException)."],"exampleFix":"// before\npublic abstract class BaseRecord { } // abstract, cannot instantiate\n// after\npublic class ConcreteRecord extends BaseRecord {\n  public ConcreteRecord() { }\n}","handlingStrategy":"validation","validationCode":"if (Modifier.isAbstract(clazz.getModifiers()) || clazz.isInterface()\n    || java.util.Arrays.stream(clazz.getDeclaredConstructors()).noneMatch(c -> c.getParameterCount() == 0)) {\n  throw new IllegalStateException(clazz + \" cannot be used with createStaticCreator\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  SchemaUserTypeCreator creator = POJOUtils.getStaticCreator(typeDescriptor, schema);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Unable to generate a creator for class\")) {\n    // register a concrete, instantiable class instead\n  } else throw e;\n}","preventionTips":["Register only concrete, public, no-arg-constructible classes with schemas.","Add a CI check that every schema-mapped class can be reflectively instantiated.","Keep @SchemaCreate factories for classes where zero-arg construction is meaningless."],"tags":["java","beam-schema","reflection","constructor"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}