{"record":{"id":"0faef4fe9030fe66","repo":"apache/beam","slug":"failed-to-create-schemaprovider-providerclass-getsimplename","errorCode":null,"errorMessage":"Failed to create SchemaProvider +providerClass.getSimpleName()+ which was specified as the default SchemaProvider for type +type+. Make  sure that this class has a public default constructor.","messagePattern":"Failed to create SchemaProvider \\+providerClass\\.getSimpleName\\(\\)\\+ which was specified as the default SchemaProvider for type \\+type\\+\\. Make  sure that this class has a public default constructor\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/annotations/DefaultSchema.java","lineNumber":109,"sourceCode":"          type -> {\n            Class<?> clazz = type.getRawType();\n            do {\n              DefaultSchema annotation = clazz.getAnnotation(DefaultSchema.class);\n              if (annotation != null) {\n                Class<? extends SchemaProvider> providerClass = annotation.value();\n                checkArgument(\n                    providerClass != null,\n                    \"Type \" + type + \" has a @DefaultSchema annotation with a null argument.\");\n\n                try {\n                  return new ProviderAndDescriptor(\n                      providerClass.getDeclaredConstructor().newInstance(),\n                      typeDescriptor.getSupertype((Class) clazz));\n                } catch (NoSuchMethodException\n                    | InstantiationException\n                    | IllegalAccessException\n                    | InvocationTargetException e) {\n                  throw new IllegalStateException(\n                      \"Failed to create SchemaProvider \"\n                          + providerClass.getSimpleName()\n                          + \" which was\"\n                          + \" specified as the default SchemaProvider for type \"\n                          + type\n                          + \". Make \"\n                          + \" sure that this class has a public default constructor.\",\n                      e);\n                }\n              }\n              clazz = clazz.getSuperclass();\n            } while (clazz != null && !clazz.equals(Object.class));\n            return null;\n          });\n    }\n\n    /**\n     * Retrieves the underlying {@link SchemaProvider} for the given {@link TypeDescriptor}. If no","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/annotations/DefaultSchema.java#L91-L127","documentation":"DefaultSchema.getSchemaProvider reflectively instantiates the class named by @DefaultSchema(...) using its no-arg constructor. If the provider class lacks a public default constructor or instantiation otherwise fails, it throws this IllegalStateException instructing the user to add a public default constructor.","triggerScenarios":"Annotating a type with @DefaultSchema(ProviderClass.class) where ProviderClass has no public no-arg constructor, is abstract, is a non-static inner class, or throws in its constructor.","commonSituations":"Typo pointing at the wrong class; making the SchemaProvider a nested inner class; giving the provider constructor parameters; provider fails during construction due to missing configuration.","solutions":["Give the SchemaProvider class a public no-arg constructor","Make the provider a static nested class or top-level class","Remove constructor parameters from the provider class","Verify the annotation points at the SchemaProvider class, not the annotated data type"],"exampleFix":"// before\nclass MySchemaProvider { MySchemaProvider(String cfg) { ... } }\n// after\nclass MySchemaProvider { public MySchemaProvider() {} ... }","handlingStrategy":"type-guard","validationCode":"Class<?> p = MySchemaProvider.class;\nif (!java.lang.reflect.Modifier.isStatic(p.getModifiers()) && p.isMemberClass()) throw new IllegalStateException(\"provider must be static or top-level\");\ntry { p.getDeclaredConstructor(); } catch (NoSuchMethodException e) { throw new IllegalStateException(\"provider needs public no-arg ctor\"); }","typeGuard":"boolean validProvider(Class<?> c) { try { return c.getDeclaredConstructor().canAccess(null) && !c.isInterface() && !java.lang.reflect.Modifier.isAbstract(c.getModifiers()); } catch (NoSuchMethodException e) { return false; } }","tryCatchPattern":"try { SchemaProvider sp = DefaultSchema.of(MySchemaProvider.class).getSchemaProvider(TypeDescriptor.of(MyType.class)); } catch (IllegalStateException e) { /* report annotation misconfiguration */ }","preventionTips":["Annotate with the provider class, not the data type","Keep SchemaProviders top-level or static nested with no-arg public constructors","Unit-test schema registration at startup"],"tags":["java","reflection","annotation"],"backgroundTag":"missing-required-config-field","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"}