{"record":{"id":"e981aa18861711a4","repo":"apache/iceberg","slug":"cannot-initialize-s3fileioawsclientfactory-missin","errorCode":null,"errorMessage":"Cannot initialize S3FileIOAwsClientFactory, missing no-arg constructor: %s","messagePattern":"Cannot initialize S3FileIOAwsClientFactory, missing no-arg constructor: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aws/src/main/java/org/apache/iceberg/aws/S3FileIOAwsClientFactories.java","lineNumber":60,"sourceCode":"    String factoryImpl =\n        PropertyUtil.propertyAsString(properties, S3FileIOProperties.CLIENT_FACTORY, null);\n    if (Strings.isNullOrEmpty(factoryImpl)) {\n      return (T) AwsClientFactories.from(properties);\n    }\n    return (T) loadClientFactory(factoryImpl, properties);\n  }\n\n  private static S3FileIOAwsClientFactory loadClientFactory(\n      String impl, Map<String, String> properties) {\n    DynConstructors.Ctor<S3FileIOAwsClientFactory> ctor;\n    try {\n      ctor =\n          DynConstructors.builder(S3FileIOAwsClientFactory.class)\n              .loader(S3FileIOAwsClientFactories.class.getClassLoader())\n              .hiddenImpl(impl)\n              .buildChecked();\n    } catch (NoSuchMethodException e) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Cannot initialize S3FileIOAwsClientFactory, missing no-arg constructor: %s\", impl),\n          e);\n    }\n\n    S3FileIOAwsClientFactory factory;\n    try {\n      factory = ctor.newInstance();\n    } catch (ClassCastException e) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Cannot initialize S3FileIOAwsClientFactory, %s does not implement S3FileIOAwsClientFactory.\",\n              impl),\n          e);\n    }\n\n    factory.initialize(properties);\n    return factory;","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/aws/src/main/java/org/apache/iceberg/aws/S3FileIOAwsClientFactories.java#L42-L78","documentation":"S3FileIOAwsClientFactories.loadClientFactory instantiates the configured custom S3FileIOAwsClientFactory implementation via DynConstructors, which looks up a no-arg constructor (possibly non-public). If the implementation lacks one, NoSuchMethodException is wrapped as this IllegalArgumentException, because factories must be instantiable without arguments before initialize(Map) is called.","triggerScenarios":"Setting s3.io-impl / the S3FileIO client factory implementation property (io.impl or similar consumed by initialize) to a class without a no-arg constructor; the class exists so Class loading succeeds but constructor lookup fails.","commonSituations":"Implementing a custom factory that takes configuration via constructor instead of initialize(Map); using a singleton-style class with a private constructor taking arguments; refactoring that added constructor parameters.","solutions":["Add a public (or at least accessible) no-arg constructor to the factory class.","Move configuration handling from the constructor into initialize(Map<String, String>).","Verify the configured implementation class name points to your factory, not another type."],"exampleFix":"// before\npublic class MyFactory implements S3FileIOAwsClientFactory {\n  public MyFactory(Map<String, String> props) { ... }\n}\n// after\npublic class MyFactory implements S3FileIOAwsClientFactory {\n  public MyFactory() {}\n  public void initialize(Map<String, String> props) { ... }\n}","handlingStrategy":"type-guard","validationCode":"Class<?> c = Class.forName(factoryClassName);\nboolean ok = java.util.Arrays.stream(c.getConstructors()).anyMatch(ctor -> ctor.getParameterCount() == 0);\nif (!ok) throw new IllegalStateException(factoryClassName + \" needs a no-arg constructor\");","typeGuard":"static boolean hasNoArgCtor(Class<?> c) {\n  try { c.getDeclaredConstructor(); return true; } catch (NoSuchMethodException e) { return false; }\n}","tryCatchPattern":"try {\n  S3FileIO io = new S3FileIO(config); // loads custom factory\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"missing no-arg constructor\")) {\n    LOG.error(\"Custom S3 client factory {} must have a no-arg constructor\", config.get(\"io.impl\"));\n  }\n  throw e;\n}","preventionTips":["Always provide a public no-arg constructor in S3FileIOAwsClientFactory implementations.","Pass configuration via initialize(Map<String, String>), not the constructor.","Add a reflective instantiation test for every custom factory class."],"tags":["aws","s3","reflection","constructor","class-not-found"],"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"}