{"record":{"id":"eddd644170f0427b","repo":"apache/beam","slug":"unable-to-generate-a-getter-for-class-clazz-with-schema","errorCode":null,"errorMessage":"Unable to generate a getter for class ${clazz} with schema ${schema}","messagePattern":"Unable to generate a getter for class (.+?) with schema (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/avro/src/main/java/org/apache/beam/sdk/extensions/avro/schemas/utils/AvroByteBuddyUtils.java","lineNumber":107,"sourceCode":"              .with(new InjectPackageStrategy(clazz))\n              .subclass(SchemaUserTypeCreator.class)\n              .method(ElementMatchers.named(\"create\"))\n              .intercept(construct);\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 getter for class \" + clazz + \" with schema \" + schema);\n    }\n  }\n\n  private static StackManipulation readAndConvertParameter(\n      Class<?> constructorParameterType, int index) {\n    TypeConversionsFactory typeConversionsFactory = new AvroUtils.AvroTypeConversionFactory();\n\n    // The types in the AVRO-generated constructor might be the types returned by Beam's Row class,\n    // so we have to convert the types used by Beam's Row class.\n    // We know that AVRO generates constructor parameters in the same order as fields\n    // in the schema, so we can just add the parameters sequentially.\n    TypeConversion<Type> convertType = typeConversionsFactory.createTypeConversion(true);\n\n    // Map the AVRO-generated type to the one Beam will use.\n    ForLoadedType convertedType =\n        new ForLoadedType((Class) convertType.convert(TypeDescriptor.of(constructorParameterType)));\n","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/avro/src/main/java/org/apache/beam/sdk/extensions/avro/schemas/utils/AvroByteBuddyUtils.java#L89-L125","documentation":"After generating the accessor bytecode, AvroByteBuddyUtils instantiates the generated class; any InstantiationException/IllegalAccessException/NoSuchMethodException/InvocationTargetException during that instantiation is rethrown as RuntimeException. It indicates the generated getter/creator class could not be constructed for the given class+schema pair.","triggerScenarios":"getCreator/createCreator hitting reflective instantiation failure — typically because the target class cannot be instantiated in the current classloader context (abstract class, missing no-arg path, restricted module access, or Java module/JDK incompatibility with ByteBuddy generation).","commonSituations":"Running on newer JDKs where ByteBuddy-generated classes fail reflective construction, classes with private/absent constructors, or mismatched schema causing bad generated bytecode parameters.","solutions":["Check the suppressed/underlying exception on the runtime error for the real reflective failure cause","Regenerate the Avro class from the current schema so bytecode matches","Disable ByteBuddy optimization (AvroUtils/AvroByteBuddyUtils toggle) to use reflection fallback","Verify JDK/Beam version compatibility for ByteBuddy"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return AvroByteBuddyUtils.getTypeCreator(clazz, schema); } catch (RuntimeException e) { return reflectivelyCreate(clazz, schema); }","preventionTips":["Check the exception's suppressed causes to find the real reflective failure","Confirm the class has accessible constructors in the executing classloader","Test ByteBuddy generation on the target JDK before deploying","Use reflection fallback when running under restricted module systems"],"tags":["avro","bytebuddy","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"}