kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 罗 辉 <luo...@zetyun.com>
Subject org.apache.kafka.common.KafkaException: Failed to construct kafka producer
Date Wed, 05 Jul 2017 11:18:31 GMT
hi guys:

  I got an exception which i searched searchhadoop.com and the archive as well and got no
matches, here it is:

log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" org.apache.kafka.common.KafkaException: Failed to construct kafka
 at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:342)
 at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:191)
 at com.zetyum.www.P$.main(P.scala:28)
 at com.zetyum.www.P.main(P.scala)
Caused by: org.apache.kafka.common.KafkaException: org.apache.kafka.common.serialization.StringDeserializer
is not an instance of org.apache.kafka.common.serialization.Serializer
 at org.apache.kafka.common.config.AbstractConfig.getConfiguredInstance(AbstractConfig.java:205)
 at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:239)
 ... 3 more

add I tried 0.11 and 0.10 for scala 2.10, both got upper exception. Here is my code:

import org.apache.kafka._
import org.apache.kafka.clients._
import org.apache.kafka.clients.producer._
import org.apache.kafka.clients.consumer._
import org.apache.kafka.common.serialization._
import java.util.Properties

object P {
  def main(args: Array[String]) {
    val brokers = "localhost:9092"
    val topic = "test"
    // Zookeeper connection properties
    val props = new Properties()
    props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokers)
    val producer = new KafkaProducer[String, String](props)
    while (true) {
      val message = new ProducerRecord[String, String](topic, "1", "1")

thanks for any advices


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