{"record":{"id":"7942c6e2c802912b","repo":"apache/beam","slug":"java-bean-s-contains-a-getter-for-field-s-but-does-not","errorCode":null,"errorMessage":"Java Bean '%s' contains a getter for field '%s', but does not contain a matching setter. %s","messagePattern":"Java Bean '(.+?)' contains a getter for field '(.+?)', but does not contain a matching setter\\. (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/JavaBeanUtils.java","lineNumber":109,"sourceCode":"      List<FieldValueTypeInformation> getters,\n      List<FieldValueTypeInformation> setters,\n      Schema schema) {\n\n    Map<String, FieldValueTypeInformation> setterMap = new HashMap<>();\n    int bound = schema.getFieldCount();\n    for (int i = 0; i < bound; i++) {\n      Integer integer = i;\n      if (setterMap.put(schema.getField(integer).getName(), setters.get(integer)) != null) {\n        throw new IllegalStateException(\"Duplicate key\");\n      }\n    }\n\n    for (FieldValueTypeInformation type : getters) {\n      FieldValueTypeInformation setterType = setterMap.get(type.getName());\n      Method m =\n          Preconditions.checkArgumentNotNull(type.getMethod(), GETTER_WITH_NULL_METHOD_ERROR);\n      if (setterType == null) {\n        throw new RuntimeException(\n            String.format(\n                \"Java Bean '%s' contains a getter for field '%s', but does not contain a matching\"\n                    + \" setter. %s\",\n                m.getDeclaringClass(), type.getName(), CONSTRUCTOR_HELP_STRING));\n      }\n      if (!type.getType().equals(setterType.getType())) {\n        throw new RuntimeException(\n            String.format(\n                \"Java Bean '%s' contains a setter for field '%s' that has a mismatching type. %s\",\n                m.getDeclaringClass(), type.getName(), CONSTRUCTOR_HELP_STRING));\n      }\n      if (!type.isNullable() == setterType.isNullable()) {\n        throw new RuntimeException(\n            String.format(\n                \"Java Bean '%s' contains a setter for field '%s' that has a mismatching nullable\"\n                    + \" attribute. %s\",\n                m.getDeclaringClass(), type.getName(), CONSTRUCTOR_HELP_STRING));\n      }","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/JavaBeanUtils.java#L91-L127","documentation":"JavaBeanUtils.validateJavaBean checks that for every getter in a Java Bean used as a schema type there is a matching setter with the same name. A getter without a setter means Beam could build a schema but could not populate instances from rows, so it throws RuntimeException. CONSTRUCTOR_HELP_STRING suggests adding a suitable constructor for defaults.","triggerScenarios":"Registering a bean class with a read-only property (getter, no setter); getter/setter naming mismatch (getX vs setVal); setter present but named differently from the getter.","commonSituations":"Immutable-style beans with only getters used with JavaBeanSchema; Lombok @Getter without @Setter (or vice versa); hand-written beans with typo'd setter names; adding a getter for a derived/computed field with no setter.","solutions":["Add a setter matching the getter name and type (setFoo for getFoo).","If the property should be read-only, exclude it from the schema (e.g. use @SchemaFieldNumber/ignore annotations per the schema provider, or remove the getter).","With Lombok add @Setter (or @Data) to the class.","If the value should be fixed, provide a constructor so Beam can create instances via constructor injection instead of setters."],"exampleFix":"// before\npublic class User { private String name; public String getName() { return name; } }\n// after\npublic class User { private String name; public String getName() { return name; } public void setName(String n) { this.name = n; } }","handlingStrategy":"validation","validationCode":"for (Method g : MyBean.class.getMethods()) if (isGetter(g)) { try { MyBean.class.getMethod(\"set\" + cap(prop(g)), g.getReturnType()); } catch (NoSuchMethodException e) { throw new IllegalStateException(\"Missing setter for \" + prop(g)); } }","typeGuard":null,"tryCatchPattern":"try { Schema.of(MyBean.class); } catch (RuntimeException e) { if (e.getMessage().contains(\"does not contain a matching\")) { /* add setter or drop getter */ } throw e; }","preventionTips":["Pair every property getter with a matching setter.","Exclude computed/read-only properties from the schema.","Add a unit test that builds a Schema from each bean class."],"tags":["java","javabean","schema","getter-setter"],"backgroundTag":"schema-validation-failed","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"}