apache/iceberg · error · IllegalArgumentException

Cannot create an instance of %s, it does not contain a stati

Error message

Cannot create an instance of %s, it does not contain a static 'create' or 'create(Map<String, String>)' method

What it means

After successfully loading the credentials provider class, AwsClientProperties.credentialsProvider instantiates it reflectively, requiring either a static create() method or a static create(Map<String, String>) method. If neither exists, NoSuchMethodException is wrapped as this IllegalArgumentException, because Iceberg instantiates providers exclusively through these factory methods.

Source

Thrown at aws/src/main/java/org/apache/iceberg/aws/AwsClientProperties.java:298

    try {
      providerClass = DynClasses.builder().impl(credentialsProviderClass).buildChecked();
    } catch (ClassNotFoundException e) {
      throw new IllegalArgumentException(
          String.format(
              "Cannot load class %s, it does not exist in the classpath", credentialsProviderClass),
          e);
    }

    Preconditions.checkArgument(
        AwsCredentialsProvider.class.isAssignableFrom(providerClass),
        String.format(
            "Cannot initialize %s, it does not implement %s.",
            credentialsProviderClass, AwsCredentialsProvider.class.getName()));

    try {
      return createCredentialsProvider(providerClass);
    } catch (NoSuchMethodException e) {
      throw new IllegalArgumentException(
          String.format(
              "Cannot create an instance of %s, it does not contain a static 'create' or 'create(Map<String, String>)' method",
              credentialsProviderClass),
          e);
    }
  }

  private AwsCredentialsProvider createCredentialsProvider(Class<?> providerClass)
      throws NoSuchMethodException {
    AwsCredentialsProvider provider;
    try {
      provider =
          DynMethods.builder("create")
              .hiddenImpl(providerClass, Map.class)
              .buildStaticChecked()
              .invoke(clientCredentialsProviderProperties);
    } catch (NoSuchMethodException e) {
      provider =

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Add a public static create() or public static create(Map<String, String>) method to the custom provider class that returns an instance.
  2. Or wrap the desired provider in a small adapter class exposing the static create method Iceberg expects.
  3. Or switch the property to a provider that already provides such a factory method.

Example fix

// before
public class MyProvider implements AwsCredentialsProvider {
  public MyProvider() {}
  public AwsCredentials resolveCredentials() { ... }
}
// after
public class MyProvider implements AwsCredentialsProvider {
  public static AwsCredentialsProvider create() { return new MyProvider(); }
  public AwsCredentials resolveCredentials() { ... }
}
Defensive patterns

Strategy: type-guard

Validate before calling

Class<?> c = Class.forName(providerClassName);
boolean ok = java.util.Arrays.stream(c.getMethods())
    .anyMatch(m -> m.getName().equals("create") && java.lang.reflect.Modifier.isStatic(m.getModifiers()));
if (!ok) throw new IllegalStateException(providerClassName + " needs static create() or create(Map)");

Type guard

static boolean hasIcebergCreateFactory(Class<?> c) {
  return java.util.Arrays.stream(c.getMethods()).anyMatch(m ->
      m.getName().equals("create") && java.lang.reflect.Modifier.isStatic(m.getModifiers())
      && (m.getParameterCount() == 0 || (m.getParameterCount() == 1 && Map.class.isAssignableFrom(m.getParameterTypes()[0]))));
}

Try / catch

try {
  io = new S3FileIO(config);
} catch (IllegalArgumentException e) {
  if (e.getMessage().contains("static 'create'")) {
    LOG.error("Add static create()/create(Map) to the provider class");
  }
  throw e;
}

Prevention

When it happens

Trigger: Configuring client.credentials-provider with a class that implements AwsCredentialsProvider but only has constructors (no static create() / create(Map) factory methods), e.g. a raw SDK provider instantiated via constructor-only patterns.

Common situations: Writing a custom AwsCredentialsProvider with only a constructor; pointing the property at an SDK provider class that lacks the Iceberg-style create factory; refactoring a provider and renaming/removing its create method.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/4d90332095158ddc. Report an issue: GitHub.