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 in Apache Kafka by akhtar
• 1,440 points
35 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 by MD
• 2,750 points

Related Questions In Apache Kafka

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
1,024 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 in Apache Kafka by MD
• 2,750 points
24 views
0 votes
1 answer

How can I create multiple consumers in apache kafka?

Hi@akhtar, If you already created multiple producers then ...READ MORE

answered Feb 6 in Apache Kafka by MD
• 2,750 points
18 views
+1 vote
1 answer
+1 vote
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,840 points
4,137 views
0 votes
1 answer

What is the importance of Kafka bootstrap.servers?

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

answered 6 days ago in Apache Kafka by MD
• 2,750 points
23 views