{"record":{"id":"acbae43f12c7c905","repo":"apache/iceberg","slug":"cannot-initialize-authmanager-implementation-s","errorCode":null,"errorMessage":"Cannot initialize AuthManager implementation %s: %s","messagePattern":"Cannot initialize AuthManager implementation (.+?): (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/rest/auth/AuthManagers.java","lineNumber":118,"sourceCode":"        break;\n      case AuthProperties.AUTH_TYPE_OAUTH2:\n        impl = AuthProperties.AUTH_MANAGER_IMPL_OAUTH2;\n        break;\n      default:\n        impl = authType;\n    }\n\n    LOG.info(\"Loading AuthManager implementation: {}\", impl);\n    DynConstructors.Ctor<AuthManager> ctor;\n    try {\n      ctor =\n          DynConstructors.builder(AuthManager.class)\n              .loader(AuthManagers.class.getClassLoader())\n              .impl(impl, String.class) // with name\n              .impl(impl, String.class, AuthManager.class) // with name and delegate\n              .buildChecked();\n    } catch (NoSuchMethodException e) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Cannot initialize AuthManager implementation %s: %s\", impl, e.getMessage()),\n          e);\n    }\n\n    AuthManager authManager;\n    try {\n      authManager = ctor.newInstance(name, delegate);\n    } catch (ClassCastException e) {\n      throw new IllegalArgumentException(\n          String.format(\"Cannot initialize AuthManager, %s does not implement AuthManager\", impl),\n          e);\n    }\n\n    return authManager;\n  }\n}\n","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/rest/auth/AuthManagers.java#L100-L136","documentation":"Thrown by AuthManagers.loadAuthManager when a custom AuthManager impl class cannot be instantiated reflectively — DynConstructors found no matching constructor taking (String name) or (String name, AuthManager delegate), e.g. class missing, not visible, or wrong constructor signature.","triggerScenarios":"Setting an AuthManager impl (via rest.auth.type=impl-class or catalog config) whose class has neither a (String) nor (String, AuthManager) constructor, or whose class cannot be loaded.","commonSituations":"Typos in the fully-qualified class name; class not on the classpath; custom AuthManager missing the required constructor; wrong constructor visibility (not public).","solutions":["Verify the class is on the runtime classpath (check for typos in the FQCN)","Add a public constructor AuthManager(String name) or (String name, AuthManager delegate)","Confirm the class implements org.apache.iceberg.rest.auth.AuthManager","Check that security providers/jars are included in the shaded/fat jar"],"exampleFix":"// before\nclass MyAuthManager {\n  MyAuthManager(String name, Map<String,String> props) { ... }\n}\n// after\nclass MyAuthManager implements AuthManager {\n  public MyAuthManager(String name) { ... }\n  public MyAuthManager(String name, AuthManager delegate) { ... }\n}","handlingStrategy":"validation","validationCode":"// pre-validate the configured impl class\nClass<?> cls = Class.forName(implClassName);\nboolean ok = AuthManager.class.isAssignableFrom(cls)\n  && java.util.Arrays.stream(cls.getConstructors())\n      .anyMatch(c -> {\n        Class<?>[] p = c.getParameterTypes();\n        return (p.length == 1 && p[0] == String.class)\n          || (p.length == 2 && p[0] == String.class && AuthManager.class.isAssignableFrom(p[1]));\n      });","typeGuard":"boolean isInstantiableAuthManager(String impl) {\n  try {\n    Class<?> c = Class.forName(impl);\n    return AuthManager.class.isAssignableFrom(c);\n  } catch (ClassNotFoundException e) { return false; }\n}","tryCatchPattern":"try { authManager = AuthManagers.loadAuthManager(config); } catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Cannot initialize AuthManager implementation\")) { /* fix impl class */ }\n  else throw e;\n}","preventionTips":["Check classpath contains the impl class jar before deployment","Provide a public (String) or (String, AuthManager) constructor","Unit-test custom AuthManagers with AuthManagers.loadAuthManager before shipping"],"tags":["auth","reflection","configuration","rest-catalog"],"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-23T08:17:48.524Z"}