org apache kafka common config ConfigException Missing required configuration bootstrap servers which has no default value

0 votes

Hi everyone,

I am new in Kafka. I am trying to run Kafka topic using Scala built tool. But It's showing me the below error.

[error] (run-main-0) org.apache.kafka.common.config.ConfigException: Missing required configuration "bootstrap.servers" which has no default value.
[error] org.apache.kafka.common.config.ConfigException: Missing required configuration "bootstrap.servers" which has no default value.
[error]         at org.apache.kafka.common.config.ConfigDef.parse(ConfigDef.java:148)
[error]         at org.apache.kafka.common.config.AbstractConfig.<init>(AbstractConfig.java:49)
[error]         at org.apache.kafka.common.config.AbstractConfig.<init>(AbstractConfig.java:56)
[error]         at org.apache.kafka.clients.producer.ProducerConfig.<init>(ProducerConfig.java:317)
[error]         at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:181)
[error]         at SimpleProducer.main(SimpleProducer.java:18)
[error]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error]         at java.lang.reflect.Method.invoke(Method.java:498)
[error] stack trace is suppressed; run last Compile / bgRun for the full output
[error] Nonzero exit code: 1
[error] (Compile / run) Nonzero exit code: 1
[error] Total time: 4 s, completed Feb 10, 2020 12:16:01 PM

Can anyone tell me how to solve it?

Thank You

Feb 10, 2020 in Apache Kafka by akhtar
• 38,260 points
7,320 views

1 answer to this question.

0 votes

Hi@akhtar,

In your file bootstrap.servers field in missing. So add that field in your file.

import java.util.*;
import org.apache.kafka.clients.producer.*;
public class SimpleProducer {
    public static void main(String[] args) throws Exception {
        String topicName = "SimpleProducerTopic";
        String key = "Key1";
        String value = "Value-1";
        Properties props = new Properties();
        props.put("bootstrap.servers", "localhost:9092,localhost:9093");
        props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        Producer<String, String> producer = new KafkaProducer<>(props);
        ProducerRecord<String, String> record = new ProducerRecord<>(topicName, key, value);
        producer.send(record);
        producer.close();
        System.out.println("SimpleProducer Completed.");
    }
}  


Check this code and modify your file.
Thank You

answered Feb 10, 2020 by MD
• 95,460 points

Related Questions In Apache Kafka

0 votes
1 answer

How can i connect to an api which gives me weather data to Apache kafka?

Hi, To connect an API in kafka, you ...READ MORE

answered Apr 13, 2020 in Apache Kafka by MD
• 95,460 points
1,359 views
0 votes
2 answers

Kafka service not starting. Shows no output

sudo systemctl status kafka This should at least ...READ MORE

answered May 9, 2019 in Apache Kafka by Novice
6,906 views
0 votes
1 answer

How can I create a topic in apache kafka?

Hi@akhtar, To create kafka topic you can use ...READ MORE

answered Feb 6, 2020 in Apache Kafka by MD
• 95,460 points
1,186 views
+1 vote
2 answers
+1 vote
1 answer
+1 vote
1 answer

What is the importance of Kafka bootstrap.servers?

Hi@akhtar, Bootstrap.servers is a mandatory field in Kafka ...READ MORE

answered Feb 11, 2020 in Apache Kafka by MD
• 95,460 points
17,754 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP