0
votes

I am trying to read the message from Kafka using consumer with the following properties

value.deserializer=io.confluent.kafka.serializers.KafkaAvroDeserializer
key.deserializer=org.apache.kafka.common.serialization.StringDeserializer
specific.avro.reader=true

And the schema is

{
      "type" : "array",
      "items" : {
          "type" : "record",
          "name" : "MyDto",
          "namespace" : "test.dto",
          "fields" : [ {
            "default" : null,
            "name" : "version",
            "type" : ["null","string"]
          }, {
            "default" : null,
            "name" : "testName",
            "type" : ["null","string"]
          }, {
            "name" : "keys",
            "type" : {"type": "array", "items": "string"},
            "java-class" : "java.util.List"
          }]
        },
      "java-class" : "java.util.List"
}

The object was written to Kafka successfully using this schema. But on deserialization I am getting exception java.lang.NoSuchMethodException: java.util.List.<init>()

Is it possible to use java.util.List class? I am using confluent 3.1.2

1

1 Answers

0
votes

A List is an interface, it has no constructor or concrete implementation. Your Producer is probably using an ArrayList, and so should the reader schema and consumer

Make sure the schema is defined with "java-class" : "java.util.ArrayList"