apache/beam · error · java.lang.RuntimeException
Unable to generate a setter for setter
Error message
Unable to generate a setter for setter '${name}' What it means
ProtoByteBuddyUtils.createOneOfSetter generates a runtime setter class for a proto oneof via Byte Buddy. If instantiating the generated class fails (InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException), it throws a RuntimeException naming the setter, with the reflective exception attached as cause.
Solutions
- Check the cause (here preserved via ', e') for the exact reflective failure
- Align org.bytebuddy dependency version with the target JDK
- Ensure the runtime allows class generation (no disallowed agents, standard JVM)
- Regenerate the schema on a supported JDK, or hand-code the setter for the affected type
Example fix
// before <dependency> net.bytebuddy:byte-buddy:1.10.x on JDK 21 // after <dependency> net.bytebuddy:byte-buddy:1.14.x (JDK 21-compatible)
Defensive patterns
Strategy: try-catch
Try / catch
try { setters.add(getProtoFieldValueSetter(...)); } catch (RuntimeException e) { if (e.getMessage().contains("Unable to generate a setter")) { LOG.error("ByteBuddy setter generation failed", e.getCause()); } throw e; } Prevention
- Match Byte Buddy version to JDK (e.g. 1.14.x for JDK 21+)
- Enable Byte Buddy type validation to surface generation errors earlier
- Test schema building on the exact runtime JDK in CI
When it happens
Trigger: Creating a proto field setter for a oneof member during schema generation when the Byte Buddy-generated class cannot be constructed (JDK/Byte Buddy incompatibility, restricted runtime, constructor signature mismatch).
Common situations: Newer JDKs with mismatched Byte Buddy versions; native-image or sandboxed environments blocking bytecode; schema generation over proto classes with unusual builders.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Unable to generate a creator for class
- Unable to generate a getter for getter
- bad decode
- bad encode
- bad type: , want
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/a13e5645dbe7c0e4.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoByteBuddyUtils.java:623
.defineConstructor(Modifier.PUBLIC)
.withParameters(List.class)
.intercept(new OneOfSetterConstructor());
List<FieldValueSetter<ProtoBuilderT, Object>> setters =
Lists.newArrayList(setterMethodMap.values());
try {
return builder
.visit(new AsmVisitorWrapper.ForDeclaredMethods().writerFlags(ClassWriter.COMPUTE_FRAMES))
.make()
.load(targetClass.getClassLoader(), getClassLoadingStrategy(targetClass))
.getLoaded()
.getDeclaredConstructor(List.class)
.newInstance(setters);
} catch (InstantiationException
| IllegalAccessException
| NoSuchMethodException
| InvocationTargetException e) {
throw new RuntimeException("Unable to generate a setter for setter '" + name + "'", e);
}
}
private static boolean isContiguous(Set<Integer> indices) {
Preconditions.checkArgument(!indices.isEmpty());
Iterator<Integer> iter = indices.iterator();
Preconditions.checkArgument(iter.hasNext());
int current = iter.next();
while (iter.hasNext()) {
if (iter.next() > current + 1) {
return false;
}
}
return true;
}
private static class OneOfGetterConstructor implements Implementation {
@OverrideView on GitHub (pinned to 12126d8942)