Kafka Client encounter "Missing required configuration "value.serializer" which has no default value

4,539 views
Skip to first unread message

Eric Zheng

unread,
Mar 15, 2015, 2:14:40 AM3/15/15
to kafka-...@googlegroups.com
I am using kafka-client 0.8.2.1, here is my demo code in Scala:

import org.apache.kafka.clients.producer.{KafkaProducer,ProducerRecord};
import java.util.Properties;

object KafkaDemo {
  def main(args: Array[String]) {
    println("Hello world!")
    val properties= new Properties()
    properties.put("metadata.broker.list", "localhost:9092")
    val producer = new KafkaProducer[Object, String](properties)
    producer.send(new ProducerRecord("test", "test content"))
  }
}


when I run the code, I encounter this:

[error] (run-main-0) org.apache.kafka.common.config.ConfigException: Missing required configuration "value.serializer" which has no default value.
org.apache.kafka.common.config.ConfigException: Missing required configuration "value.serializer" which has no default value.
at org.apache.kafka.common.config.ConfigDef.parse(ConfigDef.java:124)
at org.apache.kafka.common.config.AbstractConfig.<init>(AbstractConfig.java:48)
at org.apache.kafka.clients.producer.ProducerConfig.<init>(ProducerConfig.java:235)
at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:129)
at KafkaDemo$.main(KafkaDemo.scala:9)
at KafkaDemo.main(KafkaDemo.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)



But I follow the docs and find no "value.serializer" properties, anyway I do find a similar one "serializer.class" which is default to "kafka.serializer.default.encoder"

What is happening?

Eric Zheng

unread,
Mar 15, 2015, 2:31:57 AM3/15/15
to kafka-...@googlegroups.com
So, am I reading the wrong docs? I check the source code of Kafka-client and found out the the property key of key serializer and value serializer are respectively "key.serializer" and "value.serializer"

    public static final String KEY_SERIALIZER_CLASS_CONFIG = "key.serializer";

    public static final String VALUE_SERIALIZER_CLASS_CONFIG = "value.serializer";

And I have no way to find "serializer.class" and "key.serializer.class" from the source code at all !

Is there anything wrong about the docs?

Manikumar Reddy

unread,
Mar 15, 2015, 2:43:35 AM3/15/15
to Eric Zheng, kafka-...@googlegroups.com
looks like new producer docs missing some of these mandatory config parameters.
   

key.serializer, value.serializer config params are mandatory.They will take instance of below class
org.apache.kafka.common.serialization.Serializer.  Some of the default implementations are available in
org.apache.kafka.common.serialization package.

Simple new producer example is here:

These docs are for old producer.

--
You received this message because you are subscribed to the Google Groups "kafka-clients" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kafka-client...@googlegroups.com.
To post to this group, send email to kafka-...@googlegroups.com.
Visit this group at http://groups.google.com/group/kafka-clients.
To view this discussion on the web visit https://groups.google.com/d/msgid/kafka-clients/d14981a8-791b-4ff9-9552-8408bac5c02a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Manikumar Reddy

unread,
Mar 15, 2015, 3:04:44 AM3/15/15
to Eric Zheng, kafka-...@googlegroups.com
yeah, new producer  Kafka API docs  are pointing to old producer configs. will correct the links.


On Sun, Mar 15, 2015 at 12:24 PM, Eric Zheng <zhengw...@gmail.com> wrote:
Wow, was I directed from Kafka API docs wrongly ? It leads me to the old configuration specification. 
Anyway it's my fault that I have not noticed the new producer configuration. Thank you kumar,  I will modify my project accordingly.

Hope the API docs be refreshed soon.
--
Warmest regards!

Zheng.Weitao(郑炜韬)
University: South China University of Technology
Major : Network Engineering
Company:Tencent,Inc.
E-mail : zhengw...@gmail.com
Phone number:13570209329

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Kostya Golikov

unread,
Aug 7, 2015, 6:51:00 AM8/7/15
to kafka-clients, zhengw...@gmail.com, ku...@nmsworks.co.in
Hey, Manikumar, as far as I can see docs are still lack those vital properties.

Manikumar Reddy

unread,
Aug 7, 2015, 8:22:50 AM8/7/15
to Kostya Golikov, kafka-clients, Eric Zheng
Hi,

 This got fixed in below JIRA. But new docs will be published as part of 0.8.3 release.



Manikumar

Reply all
Reply to author
Forward
0 new messages