apache/iceberg · error · IllegalArgumentException
Cannot initialize AdlsTokenCredentialProvider, missing no-ar
Error message
Cannot initialize AdlsTokenCredentialProvider, missing no-arg constructor: %s
What it means
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.
Source
Thrown at azure/src/main/java/org/apache/iceberg/azure/AdlsTokenCredentialProviders.java:64
}
private static AdlsTokenCredentialProvider loadCredentialProvider(
String impl, Map<String, String> properties) {
if (Strings.isNullOrEmpty(impl)) {
AdlsTokenCredentialProvider provider = defaultFactory();
provider.initialize(properties);
return provider;
}
DynConstructors.Ctor<AdlsTokenCredentialProvider> ctor;
try {
ctor =
DynConstructors.builder(AdlsTokenCredentialProvider.class)
.loader(AdlsTokenCredentialProviders.class.getClassLoader())
.hiddenImpl(impl)
.buildChecked();
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException(
String.format(
"Cannot initialize AdlsTokenCredentialProvider, missing no-arg constructor: %s",
impl),
e);
}
AdlsTokenCredentialProvider provider;
try {
provider = ctor.newInstance();
} catch (ClassCastException e) {
throw new IllegalArgumentException(
String.format(
"Cannot initialize AdlsTokenCredentialProvider, %s does not implement AdlsTokenCredentialProvider.",
impl),
e);
}
provider.initialize(properties);View on GitHub (pinned to 86d9c8fc54)
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.
Example fix
// before
public MyTokenProvider(String account) { this.account = account; }
// after
public MyTokenProvider() { }
@Override public void initialize(Map<String, String> properties) { this.account = properties.get("account"); } Defensive patterns
Strategy: validation
Validate before calling
Class<?> cls = Class.forName(implClassName);
if (!AdlsTokenCredentialProvider.class.isAssignableFrom(cls)) throw new IllegalArgumentException(implClassName + " is not an AdlsTokenCredentialProvider");
try { cls.getDeclaredConstructor(); } catch (NoSuchMethodException e) { throw new IllegalArgumentException(implClassName + " needs a public no-arg constructor"); } Try / catch
try { provider = AdlsTokenCredentialProviders.from(config); } catch (IllegalArgumentException e) { log.error("Bad credential provider config: {}", e.getMessage()); throw e; } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Custom credential provider classes that only define parameterized constructors; classes requiring DI or config in constructor; anonymous/inner classes without a no-arg constructor.
Related errors
- Cannot initialize AdlsTokenCredentialProvider, %s does not i
- Failed to instantiate DynamicRecordGeneratorSQL %s
- Cannot initialize AliyunClientFactory, missing no-arg constr
- org.apache.iceberg.arrow.vectorized.ArrowVectorAccessors can
- Cannot initialize AwsClientFactory, missing no-arg construct
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/4227524f77d3fa8e.
Report an issue: GitHub.