{"record":{"id":"e52cef089a796ab6","repo":"apache/iceberg","slug":"cannot-initialize-awsclientfactory-s-does-not-im","errorCode":null,"errorMessage":"Cannot initialize AwsClientFactory, %s does not implement AwsClientFactory.","messagePattern":"Cannot initialize AwsClientFactory, (.+?) does not implement AwsClientFactory\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aws/src/main/java/org/apache/iceberg/aws/AwsClientFactories.java","lineNumber":84,"sourceCode":"  private static AwsClientFactory loadClientFactory(String impl, Map<String, String> properties) {\n    DynConstructors.Ctor<AwsClientFactory> ctor;\n    try {\n      ctor =\n          DynConstructors.builder(AwsClientFactory.class)\n              .loader(AwsClientFactories.class.getClassLoader())\n              .hiddenImpl(impl)\n              .buildChecked();\n    } catch (NoSuchMethodException e) {\n      throw new IllegalArgumentException(\n          String.format(\"Cannot initialize AwsClientFactory, missing no-arg constructor: %s\", impl),\n          e);\n    }\n\n    AwsClientFactory factory;\n    try {\n      factory = ctor.newInstance();\n    } catch (ClassCastException e) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Cannot initialize AwsClientFactory, %s does not implement AwsClientFactory.\", impl),\n          e);\n    }\n\n    factory.initialize(properties);\n    return factory;\n  }\n\n  static class DefaultAwsClientFactory implements AwsClientFactory {\n    private AwsProperties awsProperties;\n    private AwsClientProperties awsClientProperties;\n    private S3FileIOProperties s3FileIOProperties;\n    private HttpClientProperties httpClientProperties;\n\n    DefaultAwsClientFactory() {\n      awsProperties = new AwsProperties();\n      awsClientProperties = new AwsClientProperties();","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/aws/src/main/java/org/apache/iceberg/aws/AwsClientFactories.java#L66-L102","documentation":"After reflectively instantiating the class named by the client.factory-impl property, AwsClientFactories casts the new instance to AwsClientFactory. This error is thrown when the cast fails (ClassCastException), meaning the configured class exists and has a no-arg constructor but does not implement the AwsClientFactory interface. The IllegalArgumentException wraps the ClassCastException.","triggerScenarios":"Setting client.factory-impl to a class that implements a different (or stale/older-packaged) AwsClientFactory interface, or to a completely unrelated class with a no-arg constructor, e.g. a wrong class name typo that happens to resolve to another type on the classpath.","commonSituations":"Classpath containing two versions of the interface (shaded vs unshaded packages) so the implementation implements a different interface than the one DynConstructors resolves; copying a factory from another project with a different interface; typo pointing to a random no-arg class.","solutions":["Make the configured class implement org.apache.iceberg.aws.AwsClientFactory (the exact interface from the Iceberg version in use).","Check for duplicate/conflicting versions of iceberg-aws-bundle on the classpath that define a different AwsClientFactory; align versions.","Verify the fully-qualified class name in client.factory-impl is correct and matches the compiled implementation."],"exampleFix":"// before\npublic class MyFactory implements com.other.AwsClientFactory { ... }\n// after\nimport org.apache.iceberg.aws.AwsClientFactory;\npublic class MyFactory implements AwsClientFactory {\n  public s3.FileIO newS3FileIO() { ... }\n  public void initialize(Map<String, String> properties) { ... }\n}","handlingStrategy":"validation","validationCode":"Class<?> c = Class.forName(props.get(\"client.factory-impl\"));\nif (!org.apache.iceberg.aws.AwsClientFactory.class.isAssignableFrom(c)) {\n  throw new IllegalStateException(c.getName() + \" does not implement org.apache.iceberg.aws.AwsClientFactory\");\n}","typeGuard":"function implementsAwsClientFactory(Class<?> c) {\n  return org.apache.iceberg.aws.AwsClientFactory.class.isAssignableFrom(c);\n}","tryCatchPattern":"try {\n  factory = AwsClientFactories.from(props);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"does not implement AwsClientFactory\")) {\n    throw new IllegalStateException(\"Check classpath for duplicate iceberg-aws versions and confirm the impl class implements AwsClientFactory\", e);\n  }\n  throw e;\n}","preventionTips":["Implement the exact org.apache.iceberg.aws.AwsClientFactory interface matching your Iceberg version.","Keep a single version of iceberg-aws-bundle on the classpath to avoid interface identity conflicts.","Add an integration test that loads the factory via AwsClientFactories.from at startup."],"tags":["aws","reflection","classcast","configuration"],"backgroundTag":"type-mismatch","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}