KAFKA Trusted Packages Error

If you are beginner in Kafka trying to setup producer service and a consumer service — you hit upon this error

Caused by: org.apache.kafka.common.errors.SerializationException: Error deserializing key/value for partitionCaused by: java.lang.IllegalArgumentException: The class <> is not in the trusted packages: [java.util, java.lang]

Easiest way to get it up and running is to have this configuration in ProducerConfigs

props.put(JsonSerializer.ADD_TYPE_INFO_HEADERS, false);

For additional information — Read here https://docs.spring.io/spring-kafka/docs/current/reference/html/#serdes-mapping-types

and here https://stackoverflow.com/questions/66858489/spring-boot-kafka-consumer-throwing-error-in-loop

--

--