kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cassa L <lcas...@gmail.com>
Subject Error in Kafka Producer
Date Thu, 23 Jan 2014 00:51:04 GMT
Hi all,
  I am a new user of Kafka. I tried Java example of it and it worked great.
Now when I tried to write to  a Producer (Java) and send ByteArray to it as
a data, I get ClassCastException as below

java.lang.ClassCastException: java.lang.String cannot be cast to [B
    at kafka.serializer.DefaultEncoder.toBytes(Encoder.scala:34)
    at
kafka.producer.async.DefaultEventHandler$$anonfun$serialize$1.apply(DefaultEventHandler.scala:128)
    at
kafka.producer.async.DefaultEventHandler$$anonfun$serialize$1.apply(DefaultEventHandler.scala:125)
    at
scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:233)
    at
scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:233)
    at
scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:34)
    at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:33)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:233)
    at scala.collection.mutable.WrappedArray.map(WrappedArray.scala:33)
    at
kafka.producer.async.DefaultEventHandler.serialize(DefaultEventHandler.scala:125)
    at
kafka.producer.async.DefaultEventHandler.handle(DefaultEventHandler.scala:52)
    at kafka.producer.Producer.send(Producer.scala:76)
    at kafka.javaapi.producer.Producer.send(Producer.scala:33)

=====================
I am setting up Kafka properties as below -

        props.put("serializer.class", "kafka.serializer.DefaultEncoder");
        props.put("partitioner.class", "kafka.producer.DefaultPartitioner");

=====================
And I am sending data to producer as mentioned below -
        KeyedMessage<String,byte[]> data = new KeyedMessage<String, byte[]>
("Topic", key, bytearray  );
        producer.send(data);

Can someone help me understand where actually this ClassCast problem is
occurring?

..lCassa

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message