{"record":{"id":"f6f0a376d93e2bdc","repo":"apache/beam","slug":"unable-to-generate-coder-for-schema-schema","errorCode":null,"errorMessage":"Unable to generate coder for schema {schema}","messagePattern":"Unable to generate coder for schema (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/coders/RowCoderGenerator.java","lineNumber":269,"sourceCode":"              .withParameters(Coder[].class, int[].class)\n              .intercept(new GeneratedCoderConstructor());\n\n      Coder<Row> rowCoder;\n      try {\n        rowCoder =\n            builder\n                .make()\n                .load(\n                    ReflectHelpers.findClassLoader(Coder.class.getClassLoader()),\n                    getClassLoadingStrategy(Coder.class))\n                .getLoaded()\n                .getDeclaredConstructor(Coder[].class, int[].class)\n                .newInstance((Object) componentCoders, (Object) encodingPosToRowIndex);\n      } catch (InstantiationException\n          | IllegalAccessException\n          | NoSuchMethodException\n          | InvocationTargetException e) {\n        throw new RuntimeException(\"Unable to generate coder for schema \" + schema, e);\n      }\n      String stackTrace = getStackTrace();\n      GENERATED_CODERS.put(uuid, new WithStackTrace<>(rowCoder, stackTrace));\n      LOG.debug(\n          \"Created row coder for uuid {} with encoding positions {} at {}\",\n          uuid,\n          encodingPositions,\n          stackTrace);\n      return rowCoder;\n    }\n  }\n\n  private static class GeneratedCoderConstructor implements Implementation {\n    @Override\n    public InstrumentedType prepare(InstrumentedType instrumentedType) {\n      return instrumentedType;\n    }\n","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/RowCoderGenerator.java#L251-L287","documentation":"RowCoderGenerator.generate() builds a bytecode-generated RowCoder for a schema via reflection (getDeclaredConstructor/newInstance). If instantiation fails for any reason (IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException) it wraps the cause in a RuntimeException, indicating an internal Beam problem, often triggered by unsupported schema shapes or class-loading restrictions.","triggerScenarios":"Generating a RowCoder for a schema whose generated coder class cannot be constructed in the current classloader (e.g. under certain shading/Java-module setups, or a schema type whose generated coder throws in its constructor).","commonSituations":"Pipeline schema inference for a bean/POJO whose coder generation is unsupported; running under a custom ClassLoader or restrictive security manager; Beam version bug with a particular schema type.","solutions":["Upgrade to the latest Beam patch release; many generate() failures are fixed bugs","Simplify the schema: replace exotic field types with supported primitives/strings/arrays","Check the wrapped cause (`e.getCause()`) for the real constructor error and address that","Avoid custom classloading that hides the generated class from the same ClassLoader that loaded Beam"],"exampleFix":"// before\nPipeline p = ...; // schema includes unsupported field -> RuntimeException in RowCoderGenerator\n// after\n// flatten or replace unsupported field, e.g. use String/long/array types only\nSchema schema = Schema.builder().addStringField(\"id\").addInt64Field(\"count\").build();","handlingStrategy":"try-catch","validationCode":"// Validate schema field types against supported coder-generated types before building the pipeline","typeGuard":"null","tryCatchPattern":"try { Coder<Row> c = RowCoderGenerator.generate(schema); } catch (RuntimeException e) { inspect e.getCause(); }","preventionTips":["Keep Beam up to date; generated-coder bugs are fixed in patch releases","Stick to supported schema field types (primitives, String, arrays, nested schemas)","Avoid custom ClassLoaders around Beam code"],"tags":["java","beam","schema","reflection"],"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"}