{"record":{"id":"c1368b341f512b8d","repo":"apache/iceberg","slug":"cannot-initialize-lockmanager-missing-no-arg-cons","errorCode":null,"errorMessage":"Cannot initialize LockManager, missing no-arg constructor: %s","messagePattern":"Cannot initialize LockManager, missing no-arg constructor: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/util/LockManagers.java","lineNumber":62,"sourceCode":"\n  public static LockManager defaultLockManager() {\n    return LOCK_MANAGER_DEFAULT;\n  }\n\n  public static LockManager from(Map<String, String> properties) {\n    if (properties.containsKey(CatalogProperties.LOCK_IMPL)) {\n      return loadLockManager(properties.get(CatalogProperties.LOCK_IMPL), properties);\n    } else {\n      return defaultLockManager();\n    }\n  }\n\n  private static LockManager loadLockManager(String impl, Map<String, String> properties) {\n    DynConstructors.Ctor<LockManager> ctor;\n    try {\n      ctor = DynConstructors.builder(LockManager.class).hiddenImpl(impl).buildChecked();\n    } catch (NoSuchMethodException e) {\n      throw new IllegalArgumentException(\n          String.format(\"Cannot initialize LockManager, missing no-arg constructor: %s\", impl), e);\n    }\n\n    LockManager lockManager;\n    try {\n      lockManager = ctor.newInstance();\n    } catch (ClassCastException e) {\n      throw new IllegalArgumentException(\n          String.format(\"Cannot initialize LockManager, %s does not implement LockManager.\", impl),\n          e);\n    }\n\n    lockManager.initialize(properties);\n    return lockManager;\n  }\n\n  public abstract static class BaseLockManager implements LockManager {\n","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/util/LockManagers.java#L44-L80","documentation":"LockManagers.loadLockManager builds the configured LockManager implementation via DynConstructors expecting a no-arg constructor. If the class exists but has none, it throws IllegalArgumentException naming the implementation class.","triggerScenarios":"Setting lock.impl to a LockManager class that only defines parameterized constructors (custom lock managers typically require a no-arg ctor because initialize(properties) is called separately).","commonSituations":"Custom LockManager implementations that put initialization logic in a constructor with arguments; inner classes without a public no-arg constructor; copying an example class whose constructor signature was changed.","solutions":["Add a public no-arg constructor to the LockManager implementation and move logic into initialize(Map<String,String>)","Verify lock.impl points to the correct, fully-qualified concrete class","Fall back to the default in-memory lock manager for single-JVM use"],"exampleFix":"// before\nclass MyLockManager implements LockManager {\n  MyLockManager(String path) { ... }\n}\n// after\nclass MyLockManager implements LockManager {\n  public MyLockManager() { }\n  @Override\n  public void initialize(Map<String, String> properties) { this.path = properties.get(\"path\"); }\n}","handlingStrategy":"try-catch","validationCode":"Class<?> c = Class.forName(impl);\nif (!LockManager.class.isAssignableFrom(c)) throw new IllegalArgumentException(impl + \" is not a LockManager\");\nif (c.getDeclaredConstructor() == null || !java.lang.reflect.Modifier.isPublic(c.getDeclaredConstructor().getModifiers())) throw new IllegalArgumentException(impl + \" needs a public no-arg constructor\");","typeGuard":null,"tryCatchPattern":"try { LockManagers.from(properties); } catch (IllegalArgumentException e) { /* fall back to default lock manager */ }","preventionTips":["Give every custom LockManager a public no-arg constructor","Put config-driven setup in initialize(Map), not constructors","Unit-test LockManagers.from() with your configured class"],"tags":["config","reflection","lock","initialization"],"backgroundTag":"invalid-constructor-argument","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"}