C
ClearView News

WinkVibe | Kafka - Could not find a 'KafkaClient' entry in the JAAS configuration java

Author

Mia Ramsey

Published Jan 19, 2026

I'm having some troubles with a simple Kafka consumer program:

18/06/04 18:13:49 ERROR /log/log.txt: org.apache.kafka.common.KafkaException: Failed to construct kafka consumer org.apache.kafka.common.KafkaException: Failed to construct kafka consumer at org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:647) at org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:542) at org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:524) at com.carrefour.entequadratura.KafkaHandler.createConsumer(KafkaHandler.java:96) at com.carrefour.entequadratura.KafkaHandler.runConsumer(KafkaHandler.java:104) at com.carrefour.entequadratura.Main.main(Main.java:48) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:730) at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:181) at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:206) at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:121) at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala) Caused by: org.apache.kafka.common.KafkaException: java.lang.IllegalArgumentException: Could not find a 'KafkaClient' entry in the JAAS configuration. System property 'java.security.auth.login.config' is not set at org.apache.kafka.common.network.SaslChannelBuilder.configure(SaslChannelBuilder.java:74) at org.apache.kafka.common.network.ChannelBuilders.create(ChannelBuilders.java:60) at org.apache.kafka.clients.ClientUtils.createChannelBuilder(ClientUtils.java:79) at org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:577) ... 14 more Caused by: java.lang.IllegalArgumentException: Could not find a 'KafkaClient' entry in the JAAS configuration. System property 'java.security.auth.login.config' is not set at org.apache.kafka.common.security.kerberos.Login.login(Login.java:295) at org.apache.kafka.common.security.kerberos.Login.<init>(Login.java:104) at org.apache.kafka.common.security.kerberos.LoginManager.<init>(LoginManager.java:44) at org.apache.kafka.common.security.kerberos.LoginManager.acquireLoginManager(LoginManager.java:85) at org.apache.kafka.common.network.SaslChannelBuilder.configure(SaslChannelBuilder.java:55) ... 17 more 

These are my properties:

BOOTSTRAP_SERVERS=xxxxxxxxxxxxxxxxxx:6667 GROUP_ID=EnteLoader AUTO_COMMIT=false AUTO_COMMIT_INTERVAL=10000 SESSION_TIMEOUT=30000 MAX_POLL_RECORDS=5 KEY_DESERIALIZER=org.apache.kafka.common.serialization.StringDeserializer VALUE_DESERIALIZER=org.apache.kafka.common.serialization.StringDeserializer SECURITY_PROTOCOL=SASL_PLAINTEXT SASL_MECHANISM=GSSAPI SASL_KERBEROS_SERVICE_NAME=kafka 

I read about this could be a possible problem related to jaas.conf but I'm new into Kafka and I don't know how to find it..

Could you please help me? Thank you!

4

4 Answers

There are 2 ways you can pass jaas conf to your kafka consumer.

  • If you are using kafka-client version greater than 0.10.2.1 you can set a property sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="USERNAME" password="PASSWORD";

  • As your error message says you can set system property java.security.auth.login.config, For this you need to put your jaas config string to a file and give that path as value for above system property.

  • jaas.conf

    KafkaClient { org.apache.kafka.common.security.plain.PlainLoginModule required serviceName="yourServiceName" username="userName" password="password"; }; 

    Then set the environment variable:

    System.setProperty("java.security.auth.login.config","/path/to/jaas.conf"); 

    I would recommend 1st option since I have faced some issues when I went with the 2nd option.

    4

    Check your application.properties if it is set to kafka.security.protocol=SASL_PLAINTEXT

    then JAAS Authentication required to set in your property. System.setProperty("java.security.auth.login.config","/File_Location/jaas.conf");

    If you are testing your local with authentication. Set Authentication Protocol as Plain_text as

    kafka.security.protocol=PLAINTEXT

    Its tested code. Working fine for me.

    I got the same error when using spring-kafka (spring-boot version: 3.0.2, spring-cloud version: 2022.0.1). export-ing KAFKA_USERNAME and KAFKA_PASSWORD in the environment and setting properties below in spring-boot's application.yml worked for me.

    spring: kafka: properties: sasl: mechanism: PLAIN jaas: config: org.apache.kafka.common.security.plain.PlainLoginModule required username='${KAFKA_USERNAME}' password='${KAFKA_PASSWORD}'; security: protocol: SASL_SSL 
    1

    I was trying to connect to a remote Kafka broker from my local and faced the same error.

    Official Kafka docs say the same as the above answers . However, I'm unsuccessful with sasl.jaas.config hence used the static.

    Few things to note:

  • The jaas.conf content depends on the sasl.mechanism.
  • Remove the "\"(backward slash) from each new line, for example
  • sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required \ username="alice" \ password="alice-secret"; 

    becomes

    KafkaClient { org.apache.kafka.common.security.scram.ScramLoginModule required username="alice" password="alice-secret"; }; 

    Refer official doc for the right jaas.conf:

    ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobGluaGmGdoKOpJifo5FisLDBy51kp6ekYrOqusNmmGajkZu4oq%2FLopynrF2au7W%2B2Gagp2WknbJutsCaqmabn6OzqrPUq5itoZ%2Bjequt1Zo%3D