Task :core:Kafka.main() FAILED

created at 09-12-2021 views: 9

Server.properties not specified

When running directly, the error message is as follows:

> Task :core:Kafka.main() FAILED
USAGE: java [options] KafkaServer server.properties [--override property=value]*
Option               Description                                         
------               -----------                                         
--override <String>  Optional property that should override values set in
                       server.properties file        

solution

Run -> Edit Configurations..., open the dialog box shown in the figure below, and fill in config\server.properties in the Program Arguments column

Run -> Edit Configurations...

Run log is not printed

The Kafka program did start, but I don’t know what went wrong?

> Task :core:Kafka.main()
log4j:WARN No appenders could be found for logger (kafka.server.KafkaConfig).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

> Task :core:Kafka.main() FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':core:Kafka.main()'.
> Process 'command 'D:/Common/Java/jdk1.8.0_131/bin/java.exe'' finished with non-zero exit value 1

Copy the log4j.properties file in the config directory to the core/src/main/resources directory, so that Kafka can output log information at runtime:

core/src/main/resources

Connection refused

now we can see the log

[2021-09-07 09:52:16,487] INFO Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2021-09-07 09:52:17,503] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
java.net.ConnectException: Connection refused: no further information
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)
[2021-09-07 09:52:17,613] INFO Opening socket connection to server 0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2021-09-07 09:52:18,630] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
java.net.ConnectException: Connection refused: no further information
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)

2181 is the port of ZooKeeper. We know that Kafka needs ZooKeeper, so we need to install and start ZooKeeper first.

Because my current Kafka version is 1.0.0, we see that the zookeeper it relies on is 3.4.10, so I decided to also use version 3.4.10 when building the ZooKeeper service:

created at:09-12-2021
edited at: 09-12-2021: