Search code examples
scalaapache-kafkaapache-samza

Exception on samza KafkaSystemFactory.getAdmin


I am running Samza to consume messages off of a given Kafka topic in Scala. In order to run, I created a samza-read.properties file which contains:

systems.kafka.samza.factory=org.apache.samza.system.kafka.KafkaSystemFactory
systems.kafka.samza.msg.serde=byte
systems.kafka.consumer.auto.offset.reset=largest
systems.kafka.consumer.zookeeper.connect=localhost:2181/
systems.kafka.producer.bootstrap.servers=localhost:9092

Yet, when I run my program I keep getting the exception: java.lang.NoClassDefFoundError: kafka/common/ReplicaNotAvailableException at org.apache.samza.system.kafka.KafkaSystemFactory.getAdmin(KafkaSystemFactory.scala:106)

I believe this has to deal with systems.kafka.samza.factory=org.apache.samza.system.kafka.KafkaSystemFactory but maybe someone has fallen upon this exception before. Any help is greatly appreciated!


Solution

  • Looks like you have one of the following problems with your build:

    • You are missing the Kafka jar (eg: org.apache.kafka_kafka_.jar) in your class path

    • The version of the Kafka jar in your class path is incompatible with the what getAdmin is expecting

    • You possibly have 2 versions of the Kafka jar (one correct + one incorrect) and the JVM is picking up the incorrect one (fix here is to exclude the bad version in your build)