Re: Error deserializing json to Avro of schema

2,815 views
Skip to first unread message

Dustin Cote

unread,
Mar 8, 2017, 11:52:10 AM3/8/17
to confluent...@googlegroups.com
It looks like you are getting this from the console producer itself. I've been able to copy/paste your command and it works ok for me. Do you get this when the console producer starts up or when you try to send a message? If when sending a message, try a message like this as it is working for me:
{"id": 2, "created": "2016-05-06 13:54:00", "product": "OP-DAX-C-20150201-100", "price": 99.5}

This looks like a message that doesn't match the provided schema to me.

Regards,


On Wed, Mar 8, 2017 at 5:49 AM, ioannis ntantis <giann...@gmail.com> wrote:
Hi, 


when i try to set the value schema with the following command:

./kafka-avro-console-producer --broker-list localhost:9092 --topic orders-topic --property value.schema='{"type":"record","name":"myrecord","fields":[{"name":"id","type":"int"}, {"name":"created", "type": "string"}, {"name":"product", "type": "string"}, {"name":"price", "type": "double"}]}'

I get the following exception :

org.apache.kafka.common.errors.SerializationException: Error deserializing json  to Avro of schema {"type":"record","name":"myrecord","fields":[{"name":"id","type":"int"},{"name":"created","type":"string"},{"name":"product","type":"string"},{"name":"price","type":"double"}]}
Caused by: java.io.EOFException
at org.apache.avro.io.JsonDecoder.advance(JsonDecoder.java:138)
at org.apache.avro.io.JsonDecoder.readInt(JsonDecoder.java:166)
at org.apache.avro.io.ValidatingDecoder.readInt(ValidatingDecoder.java:83)
at org.apache.avro.generic.GenericDatumReader.readInt(GenericDatumReader.java:444)
at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:159)
at org.apache.avro.generic.GenericDatumReader.readField(GenericDatumReader.java:193)
at org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:183)
at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:151)
at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:142)
at io.confluent.kafka.formatter.AvroMessageReader.jsonToAvro(AvroMessageReader.java:189)
at io.confluent.kafka.formatter.AvroMessageReader.readMessage(AvroMessageReader.java:157)
at kafka.tools.ConsoleProducer$.main(ConsoleProducer.scala:55)
at kafka.tools.ConsoleProducer.main(ConsoleProducer.scala)

Also I am sure that zookeeper, kafka, schema registry and cassandra sink are running in different terminals . When I run the command i see no error in any other process such as zookeeper or kafka.

Any help would be appreciated.

Kind Regards,
Ioannis 

--
You received this message because you are subscribed to the Google Groups "Confluent Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to confluent-platform+unsub...@googlegroups.com.
To post to this group, send email to confluent-platform@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/confluent-platform/7947f115-2bfa-4af6-9418-4994522e78e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Dustin Cote
Customer Operations Engineer | Confluent
Follow us: Twitter | blog
Reply all
Reply to author
Forward
0 new messages