Morningstar / kafka-offset-monitor

A small web app to monitor the progress of kafka consumers and their lag wrt the log.
Apache License 2.0
281 stars 109 forks source link

Caused by: javax.security.auth.login.LoginException: unable to find LoginModule class: org.apache.kafka.common.security.plain.PlainLoginModule #29

Closed anjia0532 closed 6 years ago

anjia0532 commented 6 years ago

java version:

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

os version: win10 build 1709

kafka version: 1.1.0 java openjdk:8u162 scala 2.12 https://github.com/anjia0532/kafka-docker/blob/master/Dockerfile

$ cat kafka.list
    KAFKA_ADVERTISED_LISTENERS=SASL_PLAINTEXT://192.168.0.5:9092
    KAFKA_AUTO_CREATE_TOPICS=true
    KAFKA_LISTENERS=SASL_PLAINTEXT://:9092
    KAFKA_ZOOKEEPER_CONNECT=192.168.0.5:2182
    CUSTOM_INIT_SCRIPT=echo -e 'KafkaServer {\n org.apache.kafka.common.security.plain.PlainLoginModule required\n username="admin"\n password="abc"\n user_admin="abc"\n user_abc="abc";\n};' > /opt/kafka/config/kafka_server_jaas.conf
    KAFKA_SECURITY_INTER_BROKER_PROTOCOL=SASL_PLAINTEXT
    KAFKA_SASL_ENABLED_MECHANISMS=PLAIN
    KAFKA_SASL_MECHANISM_INTER_BROKER_PROTOCOL=PLAIN
    EXTRA_ARGS=-Djava.security.auth.login.config=/opt/kafka/config/kafka_server_jaas.conf

$ docker run -d --name kafka --env-file kafka.list -p9092:9092 anjia0532/kafka:2.12-1.1.0-alpine

zookeeper version: 3.4.11 java openjdk:8u151-jre https://github.com/anjia0532/zookeeper-docker/blob/master/Dockerfile

$ cat zk.list
    CUSTOM_INIT_SCRIPT=echo 1 > /opt/zk/data/myid
    ZK_clientPort=2182
    ZK_dataDir=/opt/zk/data
$ docker run -d --name zk --env-file zk.list -p2182:2182 anjia0532/zookeeper:3.4.11-alpine
# C:/kafka_client_jaas.conf
KafkaClient {
  org.apache.kafka.common.security.plain.PlainLoginModule required
  username="abc"
  password="abc";
};

 java -Djava.security.auth.login.config=C:/kafka_client_jaas.conf  -cp KafkaOffsetMonitor-assembly-0.4.6-SNAPSHOT.jar com.quantifind.kafka.offsetapp.OffsetGetterWeb --offsetStorage kafka --kafkaBrokers 127.0.0.1:9092 --zk 127.0.0.1:2182  --kafkaSecurityProtocol SASL_PLAINTEXT --port 8080 --refresh 10.seconds --retain 2.days --dbName kafka_db

error stack trace

2018-04-10 12:07:03 ERROR KafkaOffsetGetter$:103 - An unhandled exception was thrown while reading messages from the committed offsets topic.
org.apache.kafka.common.KafkaException: Failed to construct kafka consumer
    at org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:648)
    at org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:542)
    at org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:524)
    at com.quantifind.kafka.core.KafkaOffsetGetter$.createNewKafkaConsumer(KafkaOffsetGetter.scala:207)
    at com.quantifind.kafka.core.KafkaOffsetGetter$.startCommittedOffsetListener(KafkaOffsetGetter.scala:320)
    at com.quantifind.kafka.OffsetGetter$$anon$3.run(OffsetGetter.scala:289)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.kafka.common.KafkaException: javax.security.auth.login.LoginException: unable to find LoginModule class: org.apache.kafka.common.security.plain.PlainLoginModule
    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)
    ... 10 more
Caused by: javax.security.auth.login.LoginException: unable to find LoginModule class: org.apache.kafka.common.security.plain.PlainLoginModule
    at javax.security.auth.login.LoginContext.invoke(LoginContext.java:794)
    at javax.security.auth.login.LoginContext.access$000(LoginContext.java:195)
    at javax.security.auth.login.LoginContext$4.run(LoginContext.java:682)
    at javax.security.auth.login.LoginContext$4.run(LoginContext.java:680)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
    at javax.security.auth.login.LoginContext.login(LoginContext.java:587)
    at org.apache.kafka.common.security.kerberos.Login.login(Login.java:298)
    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)
    ... 13 more
rcasey212 commented 6 years ago

This project is currently running 0.9.0.1 as the Kafka client version, which does not support SASL/PLAIN authentication. Kerberos based SASL authorization is supported, however.

anjia0532 commented 6 years ago

ok ,thanks for your reply. : )