2
I was creating a simple endpoint of an entity and ended up getting the following exception:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.logpro.appcidadao.model.imovel.Imovel_$$_jvst35_0["handler"])
With some research, I came up with a solution to the problem. I added the configuration to my application.properites (jackson.erialization.FAIL_ON_EMPTY_BEANS=false)
not to serialize empty properties and noted my class as follows:
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
With this everything worked correctly. However, that’s where my doubt comes in.
My class Imovel
has only one attribute, which is id. How you are triggering the lazyInitiliazer error if the class no longer has any attribute?
Immovable Class:
@Entity
@Table(schema = "cadastro", name = "imovel")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
//@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class Imovel {
@Id
@Column(name = "imov_id")
private Integer id;
}
- Spring boot: 2.0.3
- Spring: 5.0.7