{"record":{"id":"4d90332095158ddc","repo":"apache/iceberg","slug":"cannot-create-an-instance-of-s-it-does-not-conta","errorCode":null,"errorMessage":"Cannot create an instance of %s, it does not contain a static 'create' or 'create(Map<String, String>)' method","messagePattern":"Cannot create an instance of (.+?), it does not contain a static 'create' or 'create\\(Map<String, String>\\)' method","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aws/src/main/java/org/apache/iceberg/aws/AwsClientProperties.java","lineNumber":298,"sourceCode":"    try {\n      providerClass = DynClasses.builder().impl(credentialsProviderClass).buildChecked();\n    } catch (ClassNotFoundException e) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Cannot load class %s, it does not exist in the classpath\", credentialsProviderClass),\n          e);\n    }\n\n    Preconditions.checkArgument(\n        AwsCredentialsProvider.class.isAssignableFrom(providerClass),\n        String.format(\n            \"Cannot initialize %s, it does not implement %s.\",\n            credentialsProviderClass, AwsCredentialsProvider.class.getName()));\n\n    try {\n      return createCredentialsProvider(providerClass);\n    } catch (NoSuchMethodException e) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Cannot create an instance of %s, it does not contain a static 'create' or 'create(Map<String, String>)' method\",\n              credentialsProviderClass),\n          e);\n    }\n  }\n\n  private AwsCredentialsProvider createCredentialsProvider(Class<?> providerClass)\n      throws NoSuchMethodException {\n    AwsCredentialsProvider provider;\n    try {\n      provider =\n          DynMethods.builder(\"create\")\n              .hiddenImpl(providerClass, Map.class)\n              .buildStaticChecked()\n              .invoke(clientCredentialsProviderProperties);\n    } catch (NoSuchMethodException e) {\n      provider =","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/aws/src/main/java/org/apache/iceberg/aws/AwsClientProperties.java#L280-L316","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add a public static create() or public static create(Map<String, String>) method to the custom provider class that returns an instance.","Or wrap the desired provider in a small adapter class exposing the static create method Iceberg expects.","Or switch the property to a provider that already provides such a factory method."],"exampleFix":"// before\npublic class MyProvider implements AwsCredentialsProvider {\n  public MyProvider() {}\n  public AwsCredentials resolveCredentials() { ... }\n}\n// after\npublic class MyProvider implements AwsCredentialsProvider {\n  public static AwsCredentialsProvider create() { return new MyProvider(); }\n  public AwsCredentials resolveCredentials() { ... }\n}","handlingStrategy":"type-guard","validationCode":"Class<?> c = Class.forName(providerClassName);\nboolean ok = java.util.Arrays.stream(c.getMethods())\n    .anyMatch(m -> m.getName().equals(\"create\") && java.lang.reflect.Modifier.isStatic(m.getModifiers()));\nif (!ok) throw new IllegalStateException(providerClassName + \" needs static create() or create(Map)\");","typeGuard":"static boolean hasIcebergCreateFactory(Class<?> c) {\n  return java.util.Arrays.stream(c.getMethods()).anyMatch(m ->\n      m.getName().equals(\"create\") && java.lang.reflect.Modifier.isStatic(m.getModifiers())\n      && (m.getParameterCount() == 0 || (m.getParameterCount() == 1 && Map.class.isAssignableFrom(m.getParameterTypes()[0]))));\n}","tryCatchPattern":"try {\n  io = new S3FileIO(config);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"static 'create'\")) {\n    LOG.error(\"Add static create()/create(Map) to the provider class\");\n  }\n  throw e;\n}","preventionTips":["Always give custom AwsCredentialsProvider classes a static create() factory.","Write a unit test that loads the provider through DynMethods before shipping.","Follow the Iceberg convention: configuration via create(Map), not constructors."],"tags":["aws","reflection","factory-method","invalid-constructor-argument"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}