{"record":{"id":"4227524f77d3fa8e","repo":"apache/iceberg","slug":"cannot-initialize-adlstokencredentialprovider-mis","errorCode":null,"errorMessage":"Cannot initialize AdlsTokenCredentialProvider, missing no-arg constructor: %s","messagePattern":"Cannot initialize AdlsTokenCredentialProvider, missing no-arg constructor: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"azure/src/main/java/org/apache/iceberg/azure/AdlsTokenCredentialProviders.java","lineNumber":64,"sourceCode":"  }\n\n  private static AdlsTokenCredentialProvider loadCredentialProvider(\n      String impl, Map<String, String> properties) {\n    if (Strings.isNullOrEmpty(impl)) {\n      AdlsTokenCredentialProvider provider = defaultFactory();\n      provider.initialize(properties);\n      return provider;\n    }\n\n    DynConstructors.Ctor<AdlsTokenCredentialProvider> ctor;\n    try {\n      ctor =\n          DynConstructors.builder(AdlsTokenCredentialProvider.class)\n              .loader(AdlsTokenCredentialProviders.class.getClassLoader())\n              .hiddenImpl(impl)\n              .buildChecked();\n    } catch (NoSuchMethodException e) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Cannot initialize AdlsTokenCredentialProvider, missing no-arg constructor: %s\",\n              impl),\n          e);\n    }\n\n    AdlsTokenCredentialProvider provider;\n    try {\n      provider = ctor.newInstance();\n    } catch (ClassCastException e) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Cannot initialize AdlsTokenCredentialProvider, %s does not implement AdlsTokenCredentialProvider.\",\n              impl),\n          e);\n    }\n\n    provider.initialize(properties);","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/azure/src/main/java/org/apache/iceberg/azure/AdlsTokenCredentialProviders.java#L46-L82","documentation":"AdlsTokenCredentialProviders.loadCredentialProvider reflectively instantiates a custom AdlsTokenCredentialProvider implementation from a class name. Instantiation requires a publicly accessible no-argument constructor; when DynConstructors cannot find one, this IllegalArgumentException is thrown wrapping the NoSuchMethodException.","triggerScenarios":"Passing a class name via the ADLS token credential provider config (e.g. the azure credential provider impl property) that points to a class with no public no-arg constructor.","commonSituations":"Custom credential provider classes that only define parameterized constructors; classes requiring DI or config in constructor; anonymous/inner classes without a no-arg constructor.","solutions":["Add a public no-argument constructor to the implementation class.","If the class needs configuration, implement the no-arg constructor and read config through the AdlsTokenCredentialProvider initialize/initialize-pair lifecycle methods instead of constructor parameters.","Verify the configured class name is the intended implementation and not a typo pointing at another class."],"exampleFix":"// before\npublic MyTokenProvider(String account) { this.account = account; }\n// after\npublic MyTokenProvider() { }\n@Override public void initialize(Map<String, String> properties) { this.account = properties.get(\"account\"); }","handlingStrategy":"validation","validationCode":"Class<?> cls = Class.forName(implClassName);\nif (!AdlsTokenCredentialProvider.class.isAssignableFrom(cls)) throw new IllegalArgumentException(implClassName + \" is not an AdlsTokenCredentialProvider\");\ntry { cls.getDeclaredConstructor(); } catch (NoSuchMethodException e) { throw new IllegalArgumentException(implClassName + \" needs a public no-arg constructor\"); }","typeGuard":null,"tryCatchPattern":"try { provider = AdlsTokenCredentialProviders.from(config); } catch (IllegalArgumentException e) { log.error(\"Bad credential provider config: {}\", e.getMessage()); throw e; }","preventionTips":["Always give custom providers a public no-arg constructor.","Move configuration into the provider's initialize lifecycle method instead of constructors.","Unit-test reflective loading of your custom provider class."],"tags":["azure","reflection","configuration","instantiation"],"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"}