I have been struggling with this exception for hours if not days on an Entity that references too many other entities and I have decided to annotate the entity with the LAZY annotation to improve performance gain.
With the LAZY fetch type annotation I am faced with this exception upon getting json data
No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer
Somewhere along the stacktrace, I found this error too
(to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class
I have googled and tried to disable the exception by adding this at the entity and serialize to get json with the below but unfortunately could not fetch json after the attempt
@JsonIgnoreProperties({"hibernateLazyInitializer","userId"})
class Books{
//here is the relationship
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "userId")
private User userId;
Also, I tried to disable the exception using application.properties, but still the exception still lingers after below configurations
spring.jackson.serialization.eager-serializer-fetch=true
spring.jackson.serialization.fail-on-empty-beans=false
spring.jackson.serialization.fail-on-self-references=false
spring.jackson.serialization.fail-on-unwrapped-type-identifiers=false
Please is there a way I can configure and handle this exception in ApplicationStartUp.java file. Please could someone help me get out of the dark in this