针对找不到jaas.conf文件避坑:
Exception in thread "main" org.apache.kafka.common.KafkaException: Failed to construct kafka consumer
at org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:820)
at org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:666)
at org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:646)
at com.kafka.Consumer.<init>(Consumer.java:79)
at com.kafka.Consumer.main(Consumer.java:154)
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.JaasContext.defaultContext(JaasContext.java:133)
at org.apache.kafka.common.security.JaasContext.load(JaasContext.java:98)
at org.apache.kafka.common.security.JaasContext.loadClientContext(JaasContext.java:84)
at org.apache.kafka.common.network.ChannelBuilders.create(ChannelBuilders.java:124)
at org.apache.kafka.common.network.ChannelBuilders.clientChannelBuilder(ChannelBuilders.java:67)
at org.apache.kafka.clients.ClientUtils.createChannelBuilder(ClientUtils.java:99)
at org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:741)
... 4 more
问题前提:
运行程序命令:java -cp ------------
解决办法(这只是一种很难注意到的细节,其他原因还需再次排查):文章来源:https://www.toymoban.com/news/detail-536429.html
运行命令需要在跟配置文件同级目录下运行。如:你的配置文件在/tmp/resources下,你的命令需要在/tmp下运行即可。文章来源地址https://www.toymoban.com/news/detail-536429.html
到了这里,关于Caused by: java.lang.IllegalArgumentException: Could not find a ‘KafkaClient‘ entry in the JAAS conf的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!