I'm building an older kafka (0.8.2.2) and am getting runtime errors about a missing java class:
java.lang.NoClassDefFoundError: org/apache/kafka/common/KafkaException
When I look in libs/kafka_2.10-0.8.2.2.jar, I see the existence of kafka/common/KafkaException:
$ jar tf $CLASSPATH | grep KafkaException
kafka/common/KafkaException.class
So it appears that the build (gradlew jar
) constructed the class with the org/apache
missing at the start of the class path. How do I fix the path?
You can't prepend paths to a Java class. The path must correspond to the package name. In your case the class kafka.common.KafkaException
is found in libs/kafka_2.10-0.8.2.2.jar and org.apache.kafka.common.KafkaException
is found in libs/kafka-clients-0.8.2.2.jar.
You must include libs/kafka-clients-0.8.2.2.jar in your classpath as well.