Search code examples
apache-kafkaspring-kafkaavroconfluent-schema-registry

"Error registering Avro schema" when am trying to produce data


Am trying to produce some data to my kafka topic in the format of avro schema but getting below error

org.apache.kafka.common.errors.SerializationException: Error registering Avro schema{"type":"record","name":"SampleData","namespace":"com.sample.examples","fields":[{"name":"count","type":"long"}]}
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:297) ~[kafka-schema-registry-client-7.1.1.jar:na]
    at io.confluent.kafka.schemaregistry.client.rest.RestService.httpRequest(RestService.java:367) ~[kafka-schema-registry-client-7.1.1.jar:na]
    at io.confluent.kafka.schemaregistry.client.rest.RestService.registerSchema(RestService.java:544) ~[kafka-schema-registry-client-7.1.1.jar:na]

my avro schema like below

{"namespace": "com.sample.examples",
 "type": "record",
 "name": "SampleData",
 "fields": [
     {"name": "count", "type": "long"}
 ]
}

Below are the configurations

spring.kafka.properties.bootstrap.servers=localhost:9092
spring.kafka.properties.schema.registry.url=http://localhost:8081
spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.value-serializer=io.confluent.kafka.serializers.KafkaAvroSerializer

Dependencies

    implementation 'org.apache.avro:avro:1.11.0'
          implementation 'io.confluent:kafka-schema-registry-client:7.1.1'
          implementation 'io.confluent:kafka-avro-serializer:7.1.1'
implementation 'org.springframework.kafka:spring-kafka'
    dependencies {
        classpath 'com.commercehub.gradle.plugin:gradle-avro-plugin:0.16.0'
      }

Please help me to resolve this


Solution

  • I was facing the same issue, found that MacAfee was using the same port as Schema Registry (8081) after changing the port everything was working as expected.