Error Produce Avro Records example in Confluent Cloud

I’m trying execute this command from this tutorial:
https://docs.confluent.io/platform/current/tutorials/examples/clients/docs/java.html

mvn exec:java -Dexec.mainClass="io.confluent.examples.clients.cloud.ProducerAvroExample" -Dexec.args="$HOME/.confluent/java.config test2"

And return this error:

Caused by: org.apache.kafka.common.KafkaException: Failed to create new KafkaAdminClient
    at org.apache.kafka.clients.admin.KafkaAdminClient.createInternal (KafkaAdminClient.java:537)
    at org.apache.kafka.clients.admin.KafkaAdminClient.createInternal (KafkaAdminClient.java:469)
    at org.apache.kafka.clients.admin.Admin.create (Admin.java:133)
    at org.apache.kafka.clients.admin.AdminClient.create (AdminClient.java:39)
    at io.confluent.examples.clients.cloud.ProducerAvroExample.createTopic (ProducerAvroExample.java:49)
    at io.confluent.examples.clients.cloud.ProducerAvroExample.main (ProducerAvroExample.java:73)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:829)
Caused by: java.lang.IllegalArgumentException: Login module control flag not specified in JAAS config
    at org.apache.kafka.common.security.JaasConfig.parseAppConfigurationEntry (JaasConfig.java:110)

Could you please advice how to solve this error?
Thanks in advance!

@davidleongz Welcome to the forum.

This exception is thrown when the Jaas configuration cannot be properly parsed (kafka source). I would double check the sasl.jaas.config value and ensure it follows this pattern including the spaces, quotes and semicolon.

org.apache.kafka.common.security.plain.PlainLoginModule required username='<key>' password='secret';

Here is another example that configures Java Consumers for Confluent Cloud if you’d like to compare the examples for a potential issue / difference:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.