{"record":{"id":"270bdc35f263e2d2","repo":"apache/iceberg","slug":"unable-to-find-a-constructor-for-implementation-s","errorCode":null,"errorMessage":"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.","messagePattern":"Unable to find a constructor for implementation (.+?) of (.+?)\\. 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\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/LocationProviders.java","lineNumber":52,"sourceCode":"\npublic class LocationProviders {\n\n  private LocationProviders() {}\n\n  public static LocationProvider locationsFor(\n      String inputLocation, Map<String, String> properties) {\n    String location = LocationUtil.stripTrailingSlash(inputLocation);\n    if (properties.containsKey(TableProperties.WRITE_LOCATION_PROVIDER_IMPL)) {\n      String impl = properties.get(TableProperties.WRITE_LOCATION_PROVIDER_IMPL);\n      DynConstructors.Ctor<LocationProvider> ctor;\n      try {\n        ctor =\n            DynConstructors.builder(LocationProvider.class)\n                .impl(impl, String.class, Map.class)\n                .impl(impl)\n                .buildChecked(); // fall back to no-arg constructor\n      } catch (NoSuchMethodException e) {\n        throw new IllegalArgumentException(\n            String.format(\n                \"Unable to find a constructor for implementation %s of %s. \"\n                    + \"Make sure the implementation is in classpath, and that it either \"\n                    + \"has a public no-arg constructor or a two-arg constructor \"\n                    + \"taking in the string base table location and its property string map.\",\n                impl, LocationProvider.class),\n            e);\n      }\n      try {\n        return ctor.newInstance(location, properties);\n      } catch (ClassCastException e) {\n        throw new IllegalArgumentException(\n            String.format(\n                \"Provided implementation for dynamic instantiation should implement %s.\",\n                LocationProvider.class),\n            e);\n      }\n    } else if (PropertyUtil.propertyAsBoolean(","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/LocationProviders.java#L34-L70","documentation":"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.","triggerScenarios":"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 ().","commonSituations":"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.","solutions":["Add the implementation's JAR to the driver/executor classpath","Verify the class name in write.location-provider.impl is correct and fully qualified","Implement a public constructor taking (String baseTableLocation, Map<String,String> properties) or a public no-arg constructor","Make the class public and non-abstract, implementing LocationProvider"],"exampleFix":"// before\nclass MyProvider implements LocationProvider {\n  MyProvider(String location) { ... }\n}\n// after\nclass MyProvider implements LocationProvider {\n  public MyProvider(String location, Map<String, String> properties) { ... }\n}","handlingStrategy":"try-catch","validationCode":"Class<?> clazz;\ntry {\n  clazz = Class.forName(implName);\n} catch (ClassNotFoundException e) {\n  throw new IllegalStateException(\"LocationProvider impl not on classpath: \" + implName, e);\n}\nif (!LocationProvider.class.isAssignableFrom(clazz)) {\n  throw new IllegalStateException(implName + \" does not implement LocationProvider\");\n}","typeGuard":"boolean hasValidCtor(Class<?> c) {\n  try { c.getConstructor(String.class, Map.class); return true; }\n  catch (NoSuchMethodException e) {\n    try { return java.lang.reflect.Modifier.isPublic(c.getConstructor().getModifiers()); }\n    catch (NoSuchMethodException e2) { return false; }\n  }\n}","tryCatchPattern":"try {\n  LocationProviders.locationsFor(location, props);\n} catch (IllegalArgumentException e) {\n  LOG.error(\"Bad LocationProvider impl: {}\", props.get(TableProperties.WRITE_LOCATION_PROVIDER_IMPL), e);\n  // fall back to default provider\n}","preventionTips":["Ship custom provider JARs with your job/deployment","Use the (String, Map) public constructor convention","Test provider instantiation in CI before rollout"],"tags":["java","reflection","classpath","configuration"],"backgroundTag":"class-not-found","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"}