apache/beam · error · IllegalStateException

Failed to create SchemaProvider +providerClass.getSimpleName

Error message

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.

What it means

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.

Source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/annotations/DefaultSchema.java:109

          type -> {
            Class<?> clazz = type.getRawType();
            do {
              DefaultSchema annotation = clazz.getAnnotation(DefaultSchema.class);
              if (annotation != null) {
                Class<? extends SchemaProvider> providerClass = annotation.value();
                checkArgument(
                    providerClass != null,
                    "Type " + type + " has a @DefaultSchema annotation with a null argument.");

                try {
                  return new ProviderAndDescriptor(
                      providerClass.getDeclaredConstructor().newInstance(),
                      typeDescriptor.getSupertype((Class) clazz));
                } catch (NoSuchMethodException
                    | InstantiationException
                    | IllegalAccessException
                    | InvocationTargetException e) {
                  throw new IllegalStateException(
                      "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.",
                      e);
                }
              }
              clazz = clazz.getSuperclass();
            } while (clazz != null && !clazz.equals(Object.class));
            return null;
          });
    }

    /**
     * Retrieves the underlying {@link SchemaProvider} for the given {@link TypeDescriptor}. If no

View on GitHub (pinned to 12126d8942)

Solutions

  1. Give the SchemaProvider class a public no-arg constructor
  2. Make the provider a static nested class or top-level class
  3. Remove constructor parameters from the provider class
  4. Verify the annotation points at the SchemaProvider class, not the annotated data type

Example fix

// before
class MySchemaProvider { MySchemaProvider(String cfg) { ... } }
// after
class MySchemaProvider { public MySchemaProvider() {} ... }
Defensive patterns

Strategy: type-guard

Validate before calling

Class<?> p = MySchemaProvider.class;
if (!java.lang.reflect.Modifier.isStatic(p.getModifiers()) && p.isMemberClass()) throw new IllegalStateException("provider must be static or top-level");
try { p.getDeclaredConstructor(); } catch (NoSuchMethodException e) { throw new IllegalStateException("provider needs public no-arg ctor"); }

Type guard

boolean validProvider(Class<?> c) { try { return c.getDeclaredConstructor().canAccess(null) && !c.isInterface() && !java.lang.reflect.Modifier.isAbstract(c.getModifiers()); } catch (NoSuchMethodException e) { return false; } }

Try / catch

try { SchemaProvider sp = DefaultSchema.of(MySchemaProvider.class).getSchemaProvider(TypeDescriptor.of(MyType.class)); } catch (IllegalStateException e) { /* report annotation misconfiguration */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/0faef4fe9030fe66. Report an issue: GitHub.