{"record":{"id":"dde601e68a7ba268","repo":"apache/beam","slug":"unable-to-generate-a-creator-for-class-with-schema","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/JavaBeanUtils.java","lineNumber":366,"sourceCode":"              .subclass(SchemaUserTypeCreator.class)\n              .method(ElementMatchers.named(\"create\"))\n              .intercept(\n                  new ConstructorCreateInstruction(\n                      types, clazz, constructor, typeConversionsFactory));\n      return builder\n          .visit(new AsmVisitorWrapper.ForDeclaredMethods().writerFlags(ClassWriter.COMPUTE_FRAMES))\n          .make()\n          .load(\n              ReflectHelpers.findClassLoader(clazz.getClassLoader()),\n              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  public static SchemaUserTypeCreator getStaticCreator(\n      TypeDescriptor<?> typeDescriptor,\n      Method creator,\n      Schema schema,\n      FieldValueTypeSupplier fieldValueTypeSupplier,\n      TypeConversionsFactory typeConversionsFactory) {\n    return CACHED_CREATORS.computeIfAbsent(\n        TypeDescriptorWithSchema.create(typeDescriptor, schema),\n        c -> {\n          List<FieldValueTypeInformation> types =\n              fieldValueTypeSupplier.get(typeDescriptor, schema);\n          return createStaticCreator(\n              typeDescriptor.getRawType(), creator, schema, types, typeConversionsFactory);\n        });","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/JavaBeanUtils.java#L348-L384","documentation":"JavaBeanUtils.createConstructorCreator generates a SchemaUserTypeCreator that invokes a Java bean's constructor to build rows from a Beam Schema. If instantiating the generated creator class fails via reflection (InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException), this RuntimeException naming the class and schema is thrown.","triggerScenarios":"Calling JavaBeanUtils.getConstructorCreator/createConstructorCreator for a class whose constructor-based creator cannot be instantiated: the target class lacks an accessible no-arg constructor, is abstract, or constructor invocation throws at runtime.","commonSituations":"Using a bean without a public no-arg constructor as a schema type (e.g. with Schema.create/avro-like row encoding); constructor performing validation that throws on first invocation; class visibility mismatch across packages.","solutions":["Add a public no-arg constructor to the target class and make it concrete/public","Verify the constructor parameters match the schema fields (types and order)","Catch and inspect the cause exception to see which reflective step failed","If the class cannot have a no-arg constructor, provide a static creator method instead (getStaticCreator path)"],"exampleFix":"// before\npublic class Row { public Row(String name) { ... } }\n// after\npublic class Row { public Row() {} public Row(String name) { ... } }","handlingStrategy":"validation","validationCode":"static void checkCreatorTarget(Class<?> c) {\n  if (java.lang.reflect.Modifier.isAbstract(c.getModifiers()))\n    throw new IllegalArgumentException(c + \" is abstract\");\n  try { c.getDeclaredConstructor(); }\n  catch (NoSuchMethodException e) { throw new IllegalArgumentException(\"No no-arg constructor on \" + c, e); }\n}","typeGuard":"static boolean canBeSchemaRow(Class<?> c) {\n  return java.lang.reflect.Modifier.isPublic(c.getModifiers())\n      && !c.isInterface()\n      && !java.lang.reflect.Modifier.isAbstract(c.getModifiers());\n}","tryCatchPattern":"try {\n  creator = JavaBeanUtils.getConstructorCreator(MyBean.class, schema, options);\n} catch (RuntimeException e) {\n  throw new IllegalStateException(\"Creator generation failed for \" + MyBean.class + \" with schema \" + schema, e);\n}","preventionTips":["Provide a public no-arg constructor on all schema row classes","Keep constructor parameter types aligned with schema field types","Prefer simple POJOs; avoid constructors with side effects that can throw","If no-arg ctor is impossible, expose a static factory creator instead"],"tags":["java","reflection","schemas","code-generation"],"backgroundTag":"internal-invariant-violation","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"}