{"record":{"id":"57416d0a76ff8b77","repo":"apache/iceberg","slug":"cannot-initialize-awsclientfactory-missing-no-arg","errorCode":null,"errorMessage":"Cannot initialize AwsClientFactory, missing no-arg constructor: %s","messagePattern":"Cannot initialize AwsClientFactory, missing no-arg constructor: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aws/src/main/java/org/apache/iceberg/aws/AwsClientFactories.java","lineNumber":75,"sourceCode":"  }\n\n  public static AwsClientFactory from(Map<String, String> properties) {\n    String factoryImpl =\n        PropertyUtil.propertyAsString(\n            properties, AwsProperties.CLIENT_FACTORY, DefaultAwsClientFactory.class.getName());\n    return loadClientFactory(factoryImpl, properties);\n  }\n\n  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","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/aws/src/main/java/org/apache/iceberg/aws/AwsClientFactories.java#L57-L93","documentation":"AwsClientFactories.from(properties) loads a custom AwsClientFactory implementation class named by the warehouse/client property 'client.factory-impl' via reflection (DynConstructors, hidden constructors allowed). This error is thrown when the class was found but has no accessible no-argument constructor, so it cannot be instantiated before factory.initialize(properties) is called. The IllegalArgumentException wraps the underlying NoSuchMethodException.","triggerScenarios":"Setting client.factory-impl (or the catalog's client.factory property) to a class that only has parameterized constructors, e.g. a factory requiring constructor arguments, or a class with an explicit constructor taking config so no implicit no-arg constructor exists.","commonSituations":"Users copying a factory class from an example but keeping a constructor that takes arguments; Kotlin/Scala objects or classes with required constructor params; class compiled with a constructor signature that changed between versions.","solutions":["Add a public no-argument constructor to the implementation class and receive configuration via factory.initialize(Map<String, String>).","Verify the property value points at the intended fully-qualified class name.","If the factory cannot be made no-arg, use a different customization mechanism (e.g. configure the built-in factories via catalog properties)."],"exampleFix":"// before\npublic class MyFactory implements AwsClientFactory {\n  public MyFactory(String region) { ... }\n}\n// after\npublic class MyFactory implements AwsClientFactory {\n  public MyFactory() {}\n  @Override\n  public void initialize(Map<String, String> properties) { this.region = properties.get(\"region\"); }\n}","handlingStrategy":"validation","validationCode":"String impl = props.get(\"client.factory-impl\");\nClass<?> c = Class.forName(impl);\nif (Arrays.stream(c.getConstructors()).noneMatch(ctor -> ctor.getParameterCount() == 0)) {\n  throw new IllegalStateException(impl + \" must expose a public no-arg constructor\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  factory = AwsClientFactories.from(props);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"missing no-arg constructor\")) {\n    throw new IllegalStateException(\"Fix client.factory-impl: class needs a public no-arg constructor and config via initialize()\", e);\n  }\n  throw e;\n}","preventionTips":["Always give AwsClientFactory implementations an explicit public no-arg constructor.","Pass all configuration through initialize(Map<String, String>) instead of constructor arguments.","Smoke-test factory instantiation in a startup check before creating clients."],"tags":["aws","reflection","configuration","constructor"],"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-14T11:17:12.474Z"}