Unable to find LoginModule class org.apache.kafka.common.security.plain.PlainLoginModule
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
When working with Apache Kafka and its security features, you might encounter the error message: "Unable to find LoginModule class: org.apache.kafka.common.security.plain.PlainLoginModule." This usually indicates a configuration or Classpath issue. In this article, we will explore what this error means, why it occurs, and how to fix it effectively.
Understanding the Context
Apache Kafka uses JAAS (Java Authentication and Authorization Service) for SASL (Simple Authentication and Security Layer) configurations, allowing Kafka clients and brokers to authenticate each other. The PlainLoginModule is part of Kafka's support for SASL/PLAIN mechanism, which is a simple username and password authentication method not intended for production use without SSL/TLS due to its lack of encryption.
Common Causes of the Error
- Incorrect Classpath Configuration: The required classes are not available in the application's Classpath.
- Misconfiguration in JAAS Configuration File: The JAAS configuration file might not be correctly pointing to the
PlainLoginModule. - Version Incompatibility: Using different Kafka client and broker versions might lead to this issue if the
PlainLoginModuleis not available in one of the versions.
Diagnostic Steps
- Verify ClassPath: Ensure that Kafka clients and all necessary security JAR files are included in the application’s ClassPath.
- Check JAAS Configuration File: Verify that the file is correctly formatted and accurately specifies the
PlainLoginModule. - Consistent Version Use: Check that the versions of Kafka brokers and clients are compatible.
Example of JAAS Configuration
Here's an example for the JAAS configuration using PlainLoginModule:
This configuration should be saved in a file (e.g., kafka_client_jaas.conf) and referenced in the JVM properties using -Djava.security.auth.login.config=/path/to/kafka_client_jaas.conf.
Solution Steps
- Include all Necessary Jars: Ensure all required Kafka client jars (including kafka-clients.jar and any other dependencies) are included.
- Proper JAAS File Configuration: Ensure your JAAS configuration file is correctly formatted and the path to this file is properly set in your system properties.
- Environment Specific Settings: Adjust any environment-specific settings like firewall rules or network configuration that might be blocking the authentication process.
Further Troubleshooting
- Debug Logging: Enable debug logging for SASL in Kafka clients by setting the logger to DEBUG for the
org.apache.kafkanamespace. This can provide additional insights into what might be going wrong. - Kafka Documentations and Community: Consult the Kafka documentation or community forums. Issues like this are common and might have been discussed and solved by other users.
Summary Table of Common Issues and Solutions
| Issue | Solution |
| Incorrect Classpath | Ensure all required jars are on the Classpath. |
| Incorrect JAAS configuration | Verify and correct the JAAS configuration file. |
| Version Incompatibility | Use compatible versions of Kafka clients and brokers. |
| Environmental issues | Check network, firewall, and other system settings. |
By following these guidelines, you should be able to resolve the "Unable to find LoginModule class: org.apache.kafka.common.security.plain.PlainLoginModule" error and establish a secure connection between your Kafka clients and brokers. Remember, understanding and configuring Kafka security appropriately is crucial for the safe operation of your streaming data infrastructure.
Related reading
- Unable to increase file descriptors for rabbitmq
- Unable to install confluent-kafka fatal error librdkafka/rdkafka.h No such file or directory
- Unable to list kafka topics in openwhisk setup
- Unable to produce messages to Kafka with SSL enabled
- Unable to find main class bootRepackage
- Unable to find specific subclass of NSManagedObject
- Unable to produce to Kafka topic that is running on WSL 2 from Windows
- Unable to push subsequent transactions to Kafka Producer

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.