Issue of serializer using camel-kafka component

Solution Verified - Updated -

Issue

  • Using camel-kafka component in a route camel like following:
<recipientList>
<simple>kafka:localhost:9092?topic=${in.header.topic}&amp;zookeeperHost=localhost&amp;zookeeperPort=2181&amp;requestRequiredAcks=-1</simple>
</recipientList>

we got java.lang.ClassCastException: java.lang.String cannot be cast to [B:

java.lang.ClassCastException: java.lang.String cannot be cast to [B
    at kafka.serializer.DefaultEncoder.toBytes(Encoder.scala:34)[343:org.apache.servicemix.bundles.kafka_2.10:0.8.2.0_1]
    at kafka.producer.async.DefaultEventHandler$$anonfun$serialize$1.apply(DefaultEventHandler.scala:130)[343:org.apache.servicemix.bundles.kafka_2.10:0.8.2.0_1]
    at kafka.producer.async.DefaultEventHandler$$anonfun$serialize$1.apply(DefaultEventHandler.scala:125)[343:org.apache.servicemix.bundles.kafka_2.10:0.8.2.0_1]
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)[382:org.scala-lang.scala-library:2.10.4.v20140209-180020-VFINAL-b66a39653b]
    at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:34)[382:org.scala-lang.scala-library:2.10.4.v20140209-180020-VFINAL-b66a39653b]
    at kafka.producer.async.DefaultEventHandler.serialize(DefaultEventHandler.scala:125)[343:org.apache.servicemix.bundles.kafka_2.10:0.8.2.0_1]
    at kafka.producer.async.DefaultEventHandler.handle(DefaultEventHandler.scala:52)[343:org.apache.servicemix.bundles.kafka_2.10:0.8.2.0_1]
    at kafka.producer.Producer.send(Producer.scala:77)[343:org.apache.servicemix.bundles.kafka_2.10:0.8.2.0_1]
    at kafka.javaapi.producer.Producer.send(Producer.scala:33)[343:org.apache.servicemix.bundles.kafka_2.10:0.8.2.0_1]
    at org.apache.camel.component.kafka.KafkaProducer.process(KafkaProducer.java:84)[297:org.apache.camel.camel-kafka:2.15.1.redhat-621084]
...
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to [B

Environment

  • Red Hat JBoss Fuse
    • 6.2.1

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content