kafka NoClassDefFoundError kafka/Kafka

apache-kafka, apache-zookeeper, noclassdeffounderror

Solution

You must first build Kafka by running the following commands:

> ./sbt update
> ./sbt package 

Only then will Kafka be ready for use.

Problem

Regarding Apache-Kafka messaging queue. I have downloaded Apache Kafka from the Kafka download page. I've extracted it to `/opt/apache/installed/kafka-0.7.0-incubating-src`. The quickstart page says you need to start zookeeper and then start Kafka by running: `>bin/kafka-server-start.sh config/server.properties` I'm using a separate Zookeeper server, so i edited `config/server.properties` to point to that Zookeeper instance. When i run Kafka, as instructed in the quickstart page, I get the following error: ``` Exception in thread "main" java.lang.NoClassDefFoundError: kafka/Kafka Caused by: java.lang.ClassNotFoundException: kafka.Kafka at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) Could not find the main class: kafka.Kafka. Program will exit. ``` I used telnet to make sure the Zookeeper instance is accessible from the machine that Kafka runs on. Everything is OK. Why am i getting this error?

Original source