apache/iceberg · error · IllegalArgumentException

Unable to find a constructor for implementation %s of %s. Ma

Error message

Unable to find a constructor for implementation %s of %s. Make sure the implementation is in classpath, and that it either has a public no-arg constructor or a two-arg constructor taking in the string base table location and its property string map.

What it means

LocationProviders.locationsFor dynamically instantiates a custom LocationProvider class via reflection. This error means the class could not be loaded or lacks both the required two-arg (String, Map) constructor and a public no-arg constructor, so no valid constructor exists to invoke.

Source

Thrown at core/src/main/java/org/apache/iceberg/LocationProviders.java:52

public class LocationProviders {

  private LocationProviders() {}

  public static LocationProvider locationsFor(
      String inputLocation, Map<String, String> properties) {
    String location = LocationUtil.stripTrailingSlash(inputLocation);
    if (properties.containsKey(TableProperties.WRITE_LOCATION_PROVIDER_IMPL)) {
      String impl = properties.get(TableProperties.WRITE_LOCATION_PROVIDER_IMPL);
      DynConstructors.Ctor<LocationProvider> ctor;
      try {
        ctor =
            DynConstructors.builder(LocationProvider.class)
                .impl(impl, String.class, Map.class)
                .impl(impl)
                .buildChecked(); // fall back to no-arg constructor
      } catch (NoSuchMethodException e) {
        throw new IllegalArgumentException(
            String.format(
                "Unable to find a constructor for implementation %s of %s. "
                    + "Make sure the implementation is in classpath, and that it either "
                    + "has a public no-arg constructor or a two-arg constructor "
                    + "taking in the string base table location and its property string map.",
                impl, LocationProvider.class),
            e);
      }
      try {
        return ctor.newInstance(location, properties);
      } catch (ClassCastException e) {
        throw new IllegalArgumentException(
            String.format(
                "Provided implementation for dynamic instantiation should implement %s.",
                LocationProvider.class),
            e);
      }
    } else if (PropertyUtil.propertyAsBoolean(

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Add the implementation's JAR to the driver/executor classpath
  2. Verify the class name in write.location-provider.impl is correct and fully qualified
  3. Implement a public constructor taking (String baseTableLocation, Map<String,String> properties) or a public no-arg constructor
  4. Make the class public and non-abstract, implementing LocationProvider

Example fix

// before
class MyProvider implements LocationProvider {
  MyProvider(String location) { ... }
}
// after
class MyProvider implements LocationProvider {
  public MyProvider(String location, Map<String, String> properties) { ... }
}
Defensive patterns

Strategy: try-catch

Validate before calling

Class<?> clazz;
try {
  clazz = Class.forName(implName);
} catch (ClassNotFoundException e) {
  throw new IllegalStateException("LocationProvider impl not on classpath: " + implName, e);
}
if (!LocationProvider.class.isAssignableFrom(clazz)) {
  throw new IllegalStateException(implName + " does not implement LocationProvider");
}

Type guard

boolean hasValidCtor(Class<?> c) {
  try { c.getConstructor(String.class, Map.class); return true; }
  catch (NoSuchMethodException e) {
    try { return java.lang.reflect.Modifier.isPublic(c.getConstructor().getModifiers()); }
    catch (NoSuchMethodException e2) { return false; }
  }
}

Try / catch

try {
  LocationProviders.locationsFor(location, props);
} catch (IllegalArgumentException e) {
  LOG.error("Bad LocationProvider impl: {}", props.get(TableProperties.WRITE_LOCATION_PROVIDER_IMPL), e);
  // fall back to default provider
}

Prevention

When it happens

Trigger: Setting table property write.location-provider.impl to a class that is absent from the classpath, is not public, or declares only constructors other than (String, Map) or ().

Common situations: Typo in fully-qualified class name; custom provider JAR not shipped to the engine/cluster; provider class with only a (String) or (Map) constructor; non-public nested class.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/270bdc35f263e2d2. Report an issue: GitHub.