Apache Zookeeper error on windows - Couldnot find or load main class QuorumPeerMain
Asked Answered
S

16

25

I just downloaded Kafka 2.8.0 from Apache website, and I am trying to setup using the instructions given on the website. But when I try to start zookeper server, I am getting below error:

Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain

My environment is Windows 7 64 bit. I tried to follow below e-mail chain: Apache Email Chain . But still it's having same issue.

Salas answered 30/7, 2014 at 12:47 Comment(1)
I ran into this same issue on Windows 7 64-bit and wrestled with it for a while before switching to scala version 2.9.2 which worked with these updated batch files. This tutorial was very helpful.Davison
H
86

Run these commands from your Kafka root folder:

cd bin\windows

Then run Zookeper server:

zookeeper-server-start.bat ..\..\config\zookeeper.properties

Then run Kafka server:

kafka-server-start.bat ..\..\config\server.properties


The gotcha here is to run the .bat files from the /bin/windows folder, so after you run your servers with the steps above and want to follow up with the tutorial, make sure you are running the correct batch files to create topics and whatnot, e.g.:

Create a topic:

kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

List topics:

kafka-topics.bat --list --zookeeper localhost:2181

Heater answered 30/4, 2015 at 0:17 Comment(2)
This worked for me, AFTER I moved Apache and Kafka to a folder with no spaces in the path.Wheelhorse
Yeah. for me also it worked, after moving the kafka folder directly under C:\. It didn't worked when i extracted the kafka packages into C:\Program Files\ due to space issue in the folder name.Sessile
K
17

This problem happened because you have downloaded wrong version of Kafka. On the official page

enter image description here

you have selected Source download. If you will download the binary, everything will work as expected.

Kenzie answered 25/1, 2015 at 12:10 Comment(1)
I am using the Binary , running on Mac.The zookeeper is running in another window.But when I try to start kafka, I am facing the error above.Usurer
P
15

I also got the same problem in Windows platform due to keeping the kafka_2.12-2.3.0 folder in the Program Files. I changed the Kafka directory from Program Files to C:\ drive root directory. It worked fine after executing the following commands:

First, go to the Kafka root folder:

cd C:\kafka_2.12-2.3.0

Run Zookeeper server:

bin\windows\zookeeper-server-start.bat config\zookeeper.properties

Then Run Kafka Server:

bin\windows\kafka-server-start.bat config\server.properties
Polliwog answered 16/7, 2019 at 13:48 Comment(0)
R
6

Had the same error message even though I had the correct Kafka download for my Scala version.

It ended up I was running the non-windows sh file (needed to run the bat in the windows sub-folder) and was running from within the bin folder instead of the root. Moving up to the root Kafka folder and running from there appears to have worked.

C:\kafka_2.10-0.8.2.0>bin\windows\zookeeper-server-start.bat config\zookeeper.properties

Raspberry answered 10/2, 2015 at 16:45 Comment(1)
Yes, didn't pay attention to the windows folder.Imagery
N
4

I'm running on OS X and I found that having spaces anywhere in the path leading to my Kafka base directory led to this exact error message. Renaming things without spaces solved the problem with no other fix.

As an example, my Kafka install was sitting at /Users/me/Kafka Demo/kafka_2.11-0.9.0.1 which caused that error when I tried to start Zookeeper. All I did was rename things as /Users/me/KafkaDemo/kafka_2.11-0.9.0.1 and everything worked fine.

Niobe answered 15/4, 2016 at 20:21 Comment(1)
This is exactly what my problem was, thank you so much!Incapacious
G
4

The solution for windows OS is to do the following:

  1. Download the binary version instead of the source version from the official website of Apache Kafka.
  2. Make sure the JAVA_HOME environment variable does not have a space in it (by default it is installed in Program files), follow the official installation documentation for this. https://docs.oracle.com/cd/E39271_01/general.300/eid_getting_started/src/tgs_install_jdk.html.
  3. Make sure the JRE path and KAFKA_HOME path do not have spaces in them as well.
  4. Run the zookeeper before starting Kafka.
Groceryman answered 16/2, 2019 at 13:50 Comment(1)
downloading the binary version solved the issue on windows. thanks manWoodsia
I
2

First Thing: Remove all blank space from the folder name. Second Thing: Use Powershell

Wrong Path:

d:\kafka node> .\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties

Correct Path

d:\kafka_node> .\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties

Thanks & Regards Jaiswar Vipin Kumar R.

Indicatory answered 17/6, 2020 at 12:8 Comment(1)
The problem was resolved for me by moving kafka from "C:\Program Files\Kafka" to "C:\Kafka". Didn't like the spaces.Audry
N
1

Just download the binary and follow the steps mentioned in below link. http://kafka.apache.org/07/quickstart.html

if you are facing errors like

Error: Could not find or load main class org.apache.zookeeper.server.quorum.Quorumpeermain

copy zookeeper.properties from config folder to bin folder and bin/windows folder.

Now start the like
server : run zookeeper-server-start.bat zookeeper.properties

from bin or bin/windows(if you are in window machine). It should work.

If you are still facing problem, below link would be helpful http://blog.anilot.tk/2014/08/06/Set-Up-Kafka-On-Windows/

Now try staring the Kafka server.

use the below command if you are using windows: Goto bin/windows and then run kafka-server-start.bat ../../config/server.properties

if you are trying from shell prompt, goto bin and run below command

kafka-server-start.bat ../config/server.properties 

**Make sure server.properties is present in the config folder

Nicety answered 20/2, 2015 at 22:22 Comment(0)
T
1

Yes, I too faced the same problem and tried this way which was suggested in some comments above,

First I had my Kafka in C:\Program Files, Then I moved the kafka_2.11-2.1.0 folder to C:\ directory and tried the following command and it worked

.\bin\windows\kafka-server-start.bat config\server.properties 

P.S - ran the zookeper server before starting kafka

Theriot answered 30/1, 2019 at 3:46 Comment(0)
M
0

I downloaded latest stable Kafka from Apache and instruction mentioned by Matheus Felipe worked as expected.

I downloaded binary option - Scala 2.11 @ http://kafka.apache.org/downloads

Manageable answered 17/1, 2017 at 11:12 Comment(0)
P
0

I had same problem used zookeeper-3.4.12. bin directory do not has .bat files and windows directory. Just exist .com and .sh files. .com contain operation zookeeper execute. As you can see, that has to find %JAVA%. So I just set JAVA=[my java.exe path]. And it works.

Pauli answered 29/1, 2019 at 5:36 Comment(0)
I
0

I am using below mention command in windows environment.

Confluent_home\bin\windows> zookeeper-server-start.bat ..\..\etc\kafka\zookeeper.properties

if still you are getting the same error, then please verify you folder structure, Is there any space between folder name if yes then replace with either "_" or removed completely.

I was also facing the same error.

Illstarred answered 28/3, 2020 at 22:14 Comment(0)
C
0

enter image description here

Its bit weird. But replacing the root folder name to Kafka resolved my issue. It might help one or others.

Chosen answered 19/5, 2020 at 11:29 Comment(3)
Please don't paste any code as a picture when you can just cut and paste from your screen into Stack Overflow.Satterwhite
@DavidBuck Thanks for your suggestions. Highly appreciate it. I understand there should be policy to not upload the pic. If so please confirmChosen
Many things in SO that aren't necessarily policy, but are definitely considered good or bad practice - this discussion mainly takes place on meta.stackoverflow.com. This answer for example suggests what reviewers can do to an answer containing pictures of code. There's some guidance here, too. Main rule for good answers is that they should a) answer the question, clearly and concisely, b) explain as clearly as possible why the answer helps (i.e. no code-only answers), c) post code as code.Satterwhite
C
0

Kafka docker for Windows OS

Start Zookeeper

  • Clone file /conf/zoo_sample.cfg to /conf/zoo.cfg
  • Configure Zookeeper Admin (in /conf/zoo.cfg file) netty server port by adding this line admin.serverPort=8099 at the end of the zoo.cfg file. This is to avoid the App default port 8080 conflict later.
  • Run command to start ./zkServer.cmd

Stop Zookeeper

  • Run command to stop: ./zkServer.cmd stop

Start Kafka

  • Configure Kafka (in /config/zookeeper.properties file) with the Zookeeper admin port (e.g admin.serverPort=8099)
  • Run command to start ./kafka-server-start.bat ../../config/server.properties

Stop Kafka

  • Run command to stop: ./kafka-server-stop.bat

Topics

  • Run command to create a topic: ./kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test_1
  • Run command to list all topics: ./kafka-topics.bat --list --zookeeper localhost:2181

Test Topics

  • Run command to verify if a topic was created: ./kafka-topics.bat --describe --topic test_1 --bootstrap-server localhost:9092
  • Open terminal to create an event to the topic: ./kafka-console-producer.bat --topic test_1 --bootstrap-server localhost:9092
  • Open terminal to read the event from the topic: ./kafka-console-consumer.bat --topic test_1 --from-beginning --bootstrap-server localhost:9092

Practical

  • Write some events into the Topic (at kafka-console-producer terminal): This is an event
  • Will see the events printed out from reading by the consumer (at kafka-console-consumer terminal) => This is an event

Happy coding!

Chondrule answered 13/12, 2020 at 15:21 Comment(0)
V
0

I was facing the same issue.

Change the JAVA_HOME system variable to the shortened pathname so it contains no space.

Instead of: C:\Program Files\Java\jdk1.8.0_241

Set: C:\Progra~1\Java\jdk1.8.0_241

This error can happen if any kafka .bat file references a malformed JAVA_HOME variable that contains space.

Setting the shortened pathname to the variable avoids the change to another path that contains no space and solves the problem.

Virtuosity answered 9/2, 2022 at 21:54 Comment(0)
E
-1

I used to meet the issue by running below cmd via git bash tool.

bin/zookeeper-server-start.sh config/zookeeper.properties

Solution: I switched to cygwin tool (http://cygwin.com/) to run the same cmd and I did not see the issue any more.

Englishism answered 10/5, 2018 at 7:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.