{"record":{"id":"fdd147fbc7059c86","repo":"apache/iceberg","slug":"cannot-initialize-lockmanager-s-does-not-impleme","errorCode":null,"errorMessage":"Cannot initialize LockManager, %s does not implement LockManager.","messagePattern":"Cannot initialize LockManager, (.+?) does not implement LockManager\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/util/LockManagers.java","lineNumber":70,"sourceCode":"    } 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\n    private static volatile ScheduledExecutorService scheduler;\n\n    private long acquireTimeoutMs;\n    private long acquireIntervalMs;\n    private long heartbeatIntervalMs;\n    private long heartbeatTimeoutMs;\n    private int heartbeatThreads;\n","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/util/LockManagers.java#L52-L88","documentation":"After reflectively constructing the configured class, LockManagers.loadLockManager verifies the instance implements LockManager; a ClassCastException from DynConstructors is rethrown as IllegalArgumentException stating the class does not implement LockManager. The configured 'lock.impl' class was loadable but has the wrong type.","triggerScenarios":"Setting lock.impl to a class that is not a LockManager (e.g., an unrelated utility class, or a similar-named class from a different library).","commonSituations":"Typos in the fully-qualified class name that accidentally match another class; passing a factory or builder class instead of the manager itself; classloader conflicts loading an old/incompatible version of the intended implementation.","solutions":["Set lock.impl to the fully-qualified name of a class implementing org.apache.iceberg.util.LockManager","Check that the class name is not accidentally resolving to a different class (print Class.forName result)","Ensure the JAR containing the LockManager implementation is on the runtime classpath and compatible"],"exampleFix":"// before\nproperties.put(\"lock.impl\", \"com.example.MyLockManagerImpl$Builder\");\n// after\nproperties.put(\"lock.impl\", \"com.example.MyLockManagerImpl\");","handlingStrategy":"validation","validationCode":"Class<?> c = Class.forName(impl);\nif (!LockManager.class.isAssignableFrom(c)) throw new IllegalArgumentException(impl + \" does not implement LockManager\");","typeGuard":"boolean isLockManagerImpl = LockManager.class.isAssignableFrom(Class.forName(impl));","tryCatchPattern":"try { LockManagers.from(properties); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"does not implement\")) { properties.put(\"lock.impl\", \"org.apache.iceberg.util.BaseLockManager\"); } throw e; }","preventionTips":["Verify lock.impl is the concrete manager class, not a factory/builder","Compile-time check: 'implements LockManager' in the implementation","Keep implementation JARs on the runtime classpath and version-matched"],"tags":["config","reflection","lock","type-mismatch"],"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"}