apache/iceberg · error · IllegalArgumentException
Cannot create %s to generate and configure the http client b
Error message
Cannot create %s to generate and configure the http client builder
What it means
HttpClientProperties.loadHttpClientConfigurations dynamically loads a HttpClientConfigurations implementation class and invokes its static create(Map<String, String>) method with the properties map. If no such static factory method exists, NoSuchMethodException is wrapped as this IllegalArgumentException naming the implementation class.
Source
Thrown at aws/src/main/java/org/apache/iceberg/aws/HttpClientProperties.java:275
}
/**
* Dynamically load the http client builder to avoid runtime deps requirements of both {@link
* software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient} and {@link
* software.amazon.awssdk.http.apache.ApacheHttpClient}, since including both will cause error
* described in <a href="https://github.com/apache/iceberg/issues/6715">issue#6715</a>
*/
private <T> T loadHttpClientConfigurations(String impl) {
Object httpClientConfigurations;
try {
httpClientConfigurations =
DynMethods.builder("create")
.hiddenImpl(impl, Map.class)
.buildStaticChecked()
.invoke(httpClientProperties);
return (T) httpClientConfigurations;
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException(
String.format("Cannot create %s to generate and configure the http client builder", impl),
e);
}
}
}
View on GitHub (pinned to 86d9c8fc54)
Solutions
- Add a public static T create(Map<String, String> httpClientProperties) factory method to the configured implementation class.
- Verify the configured class name refers to your custom configurations class, not an unrelated type.
- If a no-arg create exists instead, change it to accept Map<String, String>.
Example fix
// before
public class MyHttpConfig implements HttpClientConfigurations {
public static MyHttpConfig create() { return new MyHttpConfig(); }
}
// after
public class MyHttpConfig implements HttpClientConfigurations {
public static MyHttpConfig create(Map<String, String> props) { return new MyHttpConfig(); }
} Defensive patterns
Strategy: type-guard
Validate before calling
Class<?> c = Class.forName(implClassName);
boolean ok = java.util.Arrays.stream(c.getMethods()).anyMatch(m ->
m.getName().equals("create") && java.lang.reflect.Modifier.isStatic(m.getModifiers())
&& m.getParameterCount() == 1 && Map.class.isAssignableFrom(m.getParameterTypes()[0]));
if (!ok) throw new IllegalStateException(implClassName + " needs static create(Map<String, String>)"); Type guard
static boolean hasCreateMapFactory(Class<?> c) {
return java.util.Arrays.stream(c.getMethods()).anyMatch(m ->
m.getName().equals("create") && java.lang.reflect.Modifier.isStatic(m.getModifiers())
&& m.getParameterCount() == 1 && Map.class.isAssignableFrom(m.getParameterTypes()[0]));
} Try / catch
try {
httpClientProps = new HttpClientProperties(props);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("Cannot create")) {
LOG.error("Configured HTTP configurations class lacks create(Map): {}", e.getMessage());
}
throw e;
} Prevention
- Always implement custom HttpClientConfigurations with public static T create(Map<String, String>).
- Unit-test dynamic loading of the configured class before deploying.
- Keep the implementation class name in config in sync with refactors.
When it happens
Trigger: Configuring a custom HTTP client configurations class (e.g. via client.http-client-configurations-implements or the property used by urlConnectionHttpClientConfigurations/apacheHttpClientConfigurations) whose class lacks a static create(Map) method.
Common situations: Implementing a custom HttpClientConfigurations with only instance methods or a no-arg create(); pointing the property at an internal/SDK class that doesn't follow Iceberg's create(Map) convention.
Related errors
- Cannot create an instance of %s, it does not contain a stati
- Cannot create an instance of %s, it does not contain a stati
- Cannot initialize AwsClientFactory, missing no-arg construct
- Cannot initialize AwsClientFactory, %s does not implement Aw
- Unrecognized HTTP client type ${httpClientType}
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/9bab556d397267e3.
Report an issue: GitHub.