confluentinc / schema-registry

Confluent Schema Registry for Kafka
https://docs.confluent.io/current/schema-registry/docs/index.html
Other
2.22k stars 1.11k forks source link

Error registering Avro schema: -- Caused by: io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException: Cannot construct instance of `io.confluent.kafka.schemaregistry.client.rest.entities. #1958

Open khubebsiddiqui opened 3 years ago

khubebsiddiqui commented 3 years ago

The producer program is in SCALA and provided the .avsc file. The class file build on IntelliJ by using --> Lifecycle--> clean, then package.

Getting this error, also tried to change the Port of schema-registry in docker-compose.yml but getting the same error. Please suggest me:

===============================

Exception in thread "main" org.apache.kafka.common.errors.SerializationException: Error registering Avro schema: {"type":"record","name":"Customer","namespace":"com.example","fields":[{"name":"first_name","type":{"type":"string","avro.java.string":"String"},"doc":"First Name of Customer"},{"name":"last_name","type":{"type":"string","avro.java.string":"String"},"doc":"Last Name of Customer"},{"name":"age","type":"int","doc":"Age at the time of registration"},{"name":"height","type":"float","doc":"Height at the time of registration in cm"},{"name":"weight","type":"float","doc":"Weight at the time of registration in kg"},{"name":"automated_email","type":"boolean","doc":"Field indicating if the user is enrolled in marketing emails","default":true}],"version":"1"} Caused by: io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException: Cannot construct instance of io.confluent.kafka.schemaregistry.client.rest.entities.ErrorMessage (although at least one Creator exists): no int/Int-argument constructor/factory method to deserialize from Number value (404) at [Source: (sun.net.www.protocol.http.HttpURLConnection$HttpInputStream); line: 1, column: 1]; error code: 50005 at io.confluent.kafka.schemaregistry.client.rest.RestService.sendHttpRequest(RestService.java:230) at io.confluent.kafka.schemaregistry.client.rest.RestService.httpRequest(RestService.java:256) at io.confluent.kafka.schemaregistry.client.rest.RestService.registerSchema(RestService.java:356) at io.confluent.kafka.schemaregistry.client.rest.RestService.registerSchema(RestService.java:348) at io.confluent.kafka.schemaregistry.client.rest.RestService.registerSchema(RestService.java:334) at io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient.registerAndGetId(CachedSchemaRegistryClient.java:168) at io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient.register(CachedSchemaRegistryClient.java:222) at io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient.register(CachedSchemaRegistryClient.java:198) at io.confluent.kafka.serializers.AbstractKafkaAvroSerializer.serializeImpl(AbstractKafkaAvroSerializer.java:70) at io.confluent.kafka.serializers.KafkaAvroSerializer.serialize(KafkaAvroSerializer.java:53) at org.apache.kafka.common.serialization.ExtendedSerializer$Wrapper.serialize(ExtendedSerializer.java:65) at org.apache.kafka.common.serialization.ExtendedSerializer$Wrapper.serialize(ExtendedSerializer.java:55) at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:807) at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:784) at com.example.Producerexample$.main(Producerexample.scala:48) at com.example.Producerexample.main(Producerexample.scala)

khubebsiddiqui commented 3 years ago

The solution is to change the port for schemaregistry in docker-compose.yml.

I changed from 8081 to 8181.

Be sure, the port is not used by other applications

khubebsiddiqui commented 3 years ago

Also, one can add the scala-avro-tools dependency.

OneCricketeer commented 2 years ago

@khubebsiddiqui If you have found a solution, feel free to close this issue.