{"record":{"id":"52bc52f886c49119","repo":"alibaba/canal","slug":"error-the-kafka-kerberos-configuration-file-does","errorCode":null,"errorMessage":"ERROR # The kafka kerberos configuration file does not exist! please check it","messagePattern":"ERROR # The kafka kerberos configuration file does not exist! please check it","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"connector/kafka-connector/src/main/java/com/alibaba/otter/canal/connector/kafka/producer/CanalKafkaProducer.java","lineNumber":78,"sourceCode":"\n        Properties kafkaProperties = new Properties();\n        kafkaProperties.putAll(kafkaProducerConfig.getKafkaProperties());\n        kafkaProperties.put(\"max.in.flight.requests.per.connection\", 1);\n        kafkaProperties.put(\"key.serializer\", StringSerializer.class);\n        if (kafkaProducerConfig.isKerberosEnabled()) {\n            File krb5File = new File(kafkaProducerConfig.getKrb5File());\n            File jaasFile = new File(kafkaProducerConfig.getJaasFile());\n            if (krb5File.exists() && jaasFile.exists()) {\n                // 配置kerberos认证，需要使用绝对路径\n                System.setProperty(\"java.security.krb5.conf\", krb5File.getAbsolutePath());\n                System.setProperty(\"java.security.auth.login.config\", jaasFile.getAbsolutePath());\n                System.setProperty(\"javax.security.auth.useSubjectCredsOnly\", \"false\");\n                kafkaProperties.put(\"security.protocol\", \"SASL_PLAINTEXT\");\n                kafkaProperties.put(\"sasl.kerberos.service.name\", \"kafka\");\n            } else {\n                String errorMsg = \"ERROR # The kafka kerberos configuration file does not exist! please check it\";\n                logger.error(errorMsg);\n                throw new RuntimeException(errorMsg);\n            }\n        }\n        kafkaProperties.put(\"value.serializer\", KafkaMessageSerializer.class);\n        producer = new KafkaProducer<>(kafkaProperties);\n    }\n\n    private void loadKafkaProperties(Properties properties) {\n        KafkaProducerConfig kafkaProducerConfig = (KafkaProducerConfig) this.mqProperties;\n        Map<String, Object> kafkaProperties = kafkaProducerConfig.getKafkaProperties();\n        // 兼容下<=1.1.4的mq配置\n        doMoreCompatibleConvert(\"canal.mq.servers\", \"kafka.bootstrap.servers\", properties);\n        doMoreCompatibleConvert(\"canal.mq.acks\", \"kafka.acks\", properties);\n        doMoreCompatibleConvert(\"canal.mq.compressionType\", \"kafka.compression.type\", properties);\n        doMoreCompatibleConvert(\"canal.mq.retries\", \"kafka.retries\", properties);\n        doMoreCompatibleConvert(\"canal.mq.batchSize\", \"kafka.batch.size\", properties);\n        doMoreCompatibleConvert(\"canal.mq.lingerMs\", \"kafka.linger.ms\", properties);\n        doMoreCompatibleConvert(\"canal.mq.maxRequestSize\", \"kafka.max.request.size\", properties);\n        doMoreCompatibleConvert(\"canal.mq.bufferMemory\", \"kafka.buffer.memory\", properties);","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/connector/kafka-connector/src/main/java/com/alibaba/otter/canal/connector/kafka/producer/CanalKafkaProducer.java#L60-L96","documentation":"Thrown by CanalKafkaProducer.init when kerberos is enabled: it requires BOTH the krb5.conf file (java.security.krb5.conf) and the JAAS login file (java.security.auth.login.config) to exist on disk. If either File.exists() returns false, it logs the error and throws a RuntimeException before any SASL_PLAINTEXT properties are set, so the producer never starts.","triggerScenarios":"kafkaProducerConfig.getKrb5File() or getJaasFile() points to a path that does not exist on the JVM host. The check is a strict AND: both must exist; missing either trips the branch.","commonSituations":"Deploying to a new host where the kerberos config paths differ; relative paths resolved against an unexpected working directory; containerized deployment that forgot to mount the krb5/jaas volumes; typo in canal.mq.kerberos.krb5.file / canal.mq.kerberos.jaas.file properties.","solutions":["Verify both configured paths exist on the producer host: check kafkaProducerConfig.getKrb5File() and getJaasFile() values and run `ls -l` on each.","Use absolute paths for the krb5/jaas file properties to avoid working-directory ambiguity.","In containers, mount the kerberos config files and set the properties to the mounted absolute paths.","If you do not actually need kerberos, clear the krb5/jaas config properties so the kerberos branch is skipped entirely."],"exampleFix":"// before — relative paths, missing on deployed host\nFile krb5File = new File(kafkaProducerConfig.getKrb5File());\n\n// after — validate and fail with a precise message before init\nFile krb5File = new File(kafkaProducerConfig.getKrb5File());\nFile jaasFile = new File(kafkaProducerConfig.getJaasFile());\nif (!krb5File.exists()) {\n    throw new IllegalArgumentException(\"krb5.conf not found at \" + krb5File.getAbsolutePath());\n}\nif (!jaasFile.exists()) {\n    throw new IllegalArgumentException(\"jaas.conf not found at \" + jaasFile.getAbsolutePath());\n}","handlingStrategy":"validation","validationCode":"File krb5 = new File(kafkaProducerConfig.getKrb5File());\nFile jaas = new File(kafkaProducerConfig.getJaasFile());\nif (!krb5.exists() || !jaas.exists()) {\n    throw new IllegalStateException(\n        \"kerberos config missing: krb5=\" + krb5.getAbsolutePath()\n        + \" exists=\" + krb5.exists()\n        + \", jaas=\" + jaas.getAbsolutePath()\n        + \" exists=\" + jaas.exists());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute paths for krb5/jaas config files.","In containers, mount the kerberos config files as volumes.","Drop the kerberos config properties entirely if SASL/kerberos is not required."],"tags":["kafka","kerberos","security","configuration","canal-connector"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}