{"record":{"id":"f2f11f6e5a97617c","repo":"apache/beam","slug":"unable-to-generate-a-creator-for-with-schema-pojoutils","errorCode":null,"errorMessage":"Unable to generate a creator for {} with schema {}","messagePattern":"Unable to generate a creator for (.+?) 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":231,"sourceCode":"              .method(ElementMatchers.named(\"create\"))\n              .intercept(\n                  new ConstructorCreateInstruction(\n                      types, clazz, constructor, typeConversionsFactory));\n\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 \" + 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":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/POJOUtils.java#L213-L249","documentation":"createConstructorCreator generates a schema-compatible creator that calls clazz.getDeclaredConstructor().newInstance(). If reflective instantiation fails (abstract class, no no-arg constructor, inaccessible constructor, constructor throwing), it throws this RuntimeException with the class and schema in the message. Unlike error 383 the cause is also swallowed here (no `e` passed).","triggerScenarios":"Calling createConstructorCreator (via getCreator) for a type without an accessible zero-argument constructor, an abstract class or interface, a non-public constructor, or a constructor that throws at instantiation time.","commonSituations":"Non-static inner classes, Kotlin/data classes without a no-arg constructor, private default constructors, or builder-only classes being handed to schema inference.","solutions":["Add a public zero-argument constructor to the class.","Annotate an appropriate constructor or static method with @SchemaCreate so Beam does not use the default constructor path.","Make the nested class static and public; widen the constructor's visibility.","Debug the root cause by temporarily invoking clazz.getDeclaredConstructor().newInstance() yourself to see the real reflective exception."],"exampleFix":"// before\npublic class Point {\n  private Point() {} // private no-arg ctor\n  public static Point of(int x, int y) {...}\n}\n// after\npublic class Point {\n  @SchemaCreate\n  public static Point create(int x, int y) { return new Point(x, y); }\n}","handlingStrategy":"validation","validationCode":"try {\n  clazz.getDeclaredConstructor().newInstance();\n} catch (ReflectiveOperationException e) {\n  throw new IllegalStateException(clazz + \" is not reflectively instantiable: \" + e);\n}","typeGuard":null,"tryCatchPattern":"try {\n  SchemaUserTypeCreator creator = POJOUtils.getCreator(typeDescriptor, schema, factory);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Unable to generate a creator for\")) {\n    // add a no-arg constructor or @SchemaCreate and redeploy\n  } else throw e;\n}","preventionTips":["Make nested schema classes static and public.","Avoid private or absent no-arg constructors in schema-mapped types.","Test reflective instantiation of all schema POJOs in a unit test."],"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"}