{"record":{"id":"558125b70a2b7caa","repo":"apache/iceberg","slug":"provided-implementation-for-dynamic-instantiation","errorCode":null,"errorMessage":"Provided implementation for dynamic instantiation should implement %s.","messagePattern":"Provided implementation for dynamic instantiation should implement (.+?)\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/LocationProviders.java","lineNumber":64,"sourceCode":"        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(\n        properties,\n        TableProperties.OBJECT_STORE_ENABLED,\n        TableProperties.OBJECT_STORE_ENABLED_DEFAULT)) {\n      return new ObjectStoreLocationProvider(location, properties);\n    } else {\n      return new DefaultLocationProvider(location, properties);\n    }\n  }\n\n  private static final Set<String> DEPRECATED_PROPERTIES =\n      ImmutableSet.of(\n          TableProperties.OBJECT_STORE_PATH, TableProperties.WRITE_FOLDER_STORAGE_LOCATION);","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/LocationProviders.java#L46-L82","documentation":"After reflective construction, the instantiated object is cast to LocationProvider; a ClassCastException means the configured class loaded and constructed but does not implement LocationProvider, so locationsFor rejects it with this IllegalArgumentException.","triggerScenarios":"Setting write.location-provider.impl to a class that constructs successfully via a matching constructor signature but does not implement org.apache.iceberg.view.LocationProvider/org.apache.iceberg.LocationProvider (e.g., implements a different interface or none).","commonSituations":"Copying a provider implementation from another library or older Iceberg version with a different interface; generic-purpose class reused accidentally as location provider.","solutions":["Make the configured class implement org.apache.iceberg.LocationProvider","Rebuild against the Iceberg version in use so the interface matches","Point write.location-provider.impl at a built-in provider or a correct custom implementation"],"exampleFix":"// before\nclass MyProvider { public MyProvider(String l, Map<String,String> p) {} }\n// after\nclass MyProvider implements LocationProvider {\n  public MyProvider(String location, Map<String, String> properties) { ... }\n  @Override public String newDataLocation(String fileName) { ... }\n}","handlingStrategy":"type-guard","validationCode":"Class<?> c = Class.forName(implName);\nif (!LocationProvider.class.isAssignableFrom(c)) {\n  throw new IllegalStateException(implName + \" must implement LocationProvider\");\n}","typeGuard":"LocationProvider.class.isAssignableFrom(clazz)","tryCatchPattern":"try {\n  LocationProviders.locationsFor(location, props);\n} catch (IllegalArgumentException e) {\n  LOG.error(\"Impl does not implement LocationProvider: {}\", implName, e);\n}","preventionTips":["Compile custom providers against the same Iceberg version in production","Implement org.apache.iceberg.LocationProvider explicitly","Run a smoke test instantiating the provider before deploying"],"tags":["java","reflection","type-mismatch","configuration"],"backgroundTag":"type-mismatch","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"}