{"record":{"id":"eb741271b8c8640d","repo":"apache/hadoop","slug":"keytab-not-defined-in-configuration","errorCode":null,"errorMessage":"Keytab not defined in configuration","messagePattern":"Keytab not defined in configuration","errorType":"exception","errorClass":"ServletException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/server/KerberosAuthenticationHandler.java","lineNumber":152,"sourceCode":"   * It creates a Kerberos context using the principal and keytab specified in\n   * the configuration.\n   * <p>\n   * This method is invoked by the {@link AuthenticationFilter#init} method.\n   *\n   * @param config configuration properties to initialize the handler.\n   *\n   * @throws ServletException thrown if the handler could not be initialized.\n   */\n  @Override\n  public void init(Properties config) throws ServletException {\n    try {\n      String principal = config.getProperty(PRINCIPAL);\n      if (principal == null || principal.trim().length() == 0) {\n        throw new ServletException(\"Principal not defined in configuration\");\n      }\n      keytab = config.getProperty(KEYTAB, keytab);\n      if (keytab == null || keytab.trim().length() == 0) {\n        throw new ServletException(\"Keytab not defined in configuration\");\n      }\n      File keytabFile = new File(keytab);\n      if (!keytabFile.exists()) {\n        throw new ServletException(\"Keytab does not exist: \" + keytab);\n      }\n      \n      // use all SPNEGO principals in the keytab if a principal isn't\n      // specifically configured\n      final String[] spnegoPrincipals;\n      if (principal.equals(\"*\")) {\n        spnegoPrincipals = KerberosUtil.getPrincipalNames(\n            keytab, Pattern.compile(\"HTTP/.*\"));\n        if (spnegoPrincipals.length == 0) {\n          throw new ServletException(\"Principals do not exist in the keytab\");\n        }\n      } else {\n        spnegoPrincipals = new String[]{principal};\n      }","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/server/KerberosAuthenticationHandler.java#L134-L170","documentation":"Error \"Keytab not defined in configuration\" thrown in apache/hadoop.","triggerScenarios":"Raised at runtime when the documented precondition or configuration requirement for this operation is violated.","commonSituations":"Misconfigured or missing property, invalid user input, or calling the API before its prerequisites are met.","solutions":["Set the keytab file path in the handler configuration (kerberos.keytab property)."],"exampleFix":"Add init-param kerberos.keytab=/etc/security/keytabs/spnego.service.keytab.","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}