Search code examples
apache-kafkakafka-producer-api

Kafka(0.9.0.0) gives ArrayIndexOutOfBoundsException


Steps followed:

cd /opt/kafka_2.11-0.9.0.0

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

bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1  --partitions 1 --topic topic-test

bin/kafka-topics.sh --list --zookeeper localhost:2181

bin/kafka-console-producer.sh --broker-list localhost:9092 --topic topic-test

Time of occurance: The moment You write anything in the producer bash this error starts coming up

Already Tried: eleting topics from zookeper bash and removing topic logs in tmp location

[2018-10-25 10:03:17,919] INFO [Kafka Server 0], started (kafka.server.KafkaServer)
[2018-10-25 10:03:18,080] INFO [ReplicaFetcherManager on broker 0] Removed fetcher for partitions [topic-test,0] (kafka.server.ReplicaFetcherManager)
[2018-10-25 10:03:18,099] INFO [ReplicaFetcherManager on broker 0] Removed fetcher for partitions [topic-test,0] (kafka.server.ReplicaFetcherManager)
[2018-10-25 10:03:48,864] ERROR Processor got uncaught exception. (kafka.network.Processor)
java.lang.ArrayIndexOutOfBoundsException: 18
    at org.apache.kafka.common.protocol.ApiKeys.forId(ApiKeys.java:68)
    at org.apache.kafka.common.requests.AbstractRequest.getRequest(AbstractRequest.java:39)
    at kafka.network.RequestChannel$Request.<init>(RequestChannel.scala:79)
    at kafka.network.Processor$$anonfun$run$11.apply(SocketServer.scala:426)
    at kafka.network.Processor$$anonfun$run$11.apply(SocketServer.scala:421)
    at scala.collection.Iterator$class.foreach(Iterator.scala:742)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1194)
    at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
    at kafka.network.Processor.run(SocketServer.scala:421)
    at java.lang.Thread.run(Thread.java:748)

It would be very helpful if someone provides a deep insight for trouble shooting other error like this in the future.


Solution

  • I downloaded the latest /kafka_2.11-2.0.0 and followed the steps:

    bin/zookeeper-server-start.sh config/zookeeper.properties 
    bin/kafka-server-start.sh config/server.properties 
    bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic topic-test 
    bin/kafka-console-producer.sh --broker-list localhost:9092 --topic topic-test 
    bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic topic-test --from-beginning 
    

    Things working fine. Please note --bootstrap-server localhost:9092 has changed in consumer script