Reputation: 58
When I am creating consumer and trying to deserialize object I got error
Caused by: IllegalArgumentException: The class 'com.domain.project2.package2.SomeEvent' is not in the trusted packages: [java.util, java.lang, com.domain.project2.package1, com.domain.project2.package2]. If you belive this class is....
My .yml config:
spring:
kafka:
bootstrap-servers: localhost:9092
producer:
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: org.apache.kafka.support.serializer.JsonSerializer
consumer:
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
value-deserializer: org.apache.kafka.support.serializer.JsonDeserializer
properties:
spring:
json:
trusted:
packages: 'com.domain.project2.package1, com.domain.project2.package2'
Upvotes: 0
Views: 317
Reputation: 174699
I presume you mean
spring:
kafka:
bootstrap-servers: localhost:9092
producer:
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
consumer:
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer
properties:
spring:
json:
trusted:
packages: 'com.domain.project2.package1, com.domain.project2.package2'
Since you are using the Spring deserializer, not the apache JsonDeserializer
.
The problem is the space after the comma.
Use 'com.domain.project2.package1,com.domain.project2.package2'
.
We should probably trim the packages to remove extraneous spaces.
Upvotes: 1