简体   繁体   English

Kafka Streams:JAAS 配置中未指定登录模块控制标志

[英]Kafka Streams: Login module control flag not specified in JAAS config

I am trying to run my Kafka Streams app using Java and passing my Confluent credentials as Environment variables in the form of K,V pair.我正在尝试使用 Java 运行我的 Kafka Streams 应用程序,并将我的 Confluent 凭据以 K、V 对的形式作为环境变量传递。

But I am facing an issue with error as -但我面临一个错误问题,因为 -

- org.apache.kafka.common.KafkaException: Failed to create new KafkaAdminClient 
Exception in thread "main" org.apache.kafka.common.KafkaException: Failed to create new KafkaAdminClient
Caused by: java.lang.IllegalArgumentException: Login module control flag not specified in JAAS config

Here is how I am setting my Kafka Properties -这是我设置 Kafka 属性的方式 -

Properties kafkaProps = new Properties();
kafkaProps.put(StreamsConfig.APPLICATION_ID_CONFIG, "MyKafkaApplicationV1.0.0");
kafkaProps.put(StreamsConfig.STATE_DIR_CONFIG, "tmp/state-store");
kafkaProps.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, System.getenv("bootstarpServers"));
kafkaProps.put(StreamsConfig.SECURITY_PROTOCOL_CONFIG, System.getenv("securityProtocol"));

kafkaProps.put(SaslConfigs.SASL_JAAS_CONFIG, System.getenv(SASL_JAAS_CONFIG));
kafkaProps.put(SaslConfigs.SASL_MECHANISM, System.getenv(SASL_MECHANISM));

Here is how I am passing the environment variables -这是我传递环境变量的方式 -

export saslJaasConfig=org.apache.kafka.common.security.plain.PlainLoginModule required username='MyUserName' password='MyPassword';
export saslMechanism=PLAIN

But if I hardcode the Creds string directly in the properties object like - kafkaProps.put(SaslConfigs.SASL_JAAS_CONFIG, "org.apache.kafka.common.security.plain.PlainLoginModule required username='MyUserName' password='MyPassword';");但是,如果我直接在属性 object 中对 Creds 字符串进行硬编码,例如 - kafkaProps.put(SaslConfigs.SASL_JAAS_CONFIG, "org.apache.kafka.common.security.plain.PlainLoginModule required username='MyUserName' password='MyPassword';"); then it's working and showing no error.然后它正在工作并且没有显示错误。

Kindly help on what am I missing.!请帮助我缺少什么。! Thanks in advance.提前致谢。

You can pass the jass config as jvm argument.Please try this.您可以将 jass 配置作为 jvm 参数传递。请试试这个。

-Djava.security.auth.login.config=jaas_config.conf -Djava.security.auth.login.config=jaas_config.conf

contents of jaas_config.conf jaas_config.conf 的内容

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM