본문 바로가기
Spring/오류잡기

[FetchType.Lazy로 인한 Json 오류] Type definition error: [simple type, class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException

by MINNI_ 2022. 1. 14.

1. 오류

  • FetchType.Lazy로 인한 Json 오류
There was an unexpected error (type=Internal Server Error, status=500).
Type definition error: [simple type, class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.ArrayList[0]->com.moviewiki.api.actorFilmography.domain.ActorFilmography["actor"]->com.moviewiki.api.actor.domain.Actor$HibernateProxy$cvpvWkie["hibernateLazyInitializer"])
org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.ArrayList[0]->com.moviewiki.api.actorFilmography.domain.ActorFilmography["actor"]->com.moviewiki.api.actor.domain.Actor$HibernateProxy$cvpvWkie["hibernateLazyInitializer"])
	at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.writeInternal(AbstractJackson2HttpMessageConverter.java:460)
	at org.springframework.http.converter.AbstractGenericHttpMessageConverter.write(AbstractGenericHttpMessageConverter.java:104)
	at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:290)
	at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:183)
	at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:78)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:135)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)

2. 해결방법

https://ahndding.tistory.com/24

 

[JPA] FetchType.Lazy로 인한 JSON 오류 (InvalidDefinitionException: No serializer found for class)

발단 Front에서 엔티티를 저장하는 과정에서 처음 데이터를 저장하는 순간에는 올바르게 작동하지만 수정(edit)하고 저장할 때에는 에러(HttpStatus 500)를 리턴한다는 문제가 발생했다. (다만 DB상으

ahndding.tistory.com

 

https://kim-daeyong.github.io/2019-02-18-%EC%97%94%ED%8B%B0%ED%8B%B0%EC%A0%9C%EC%9D%B4%EC%8A%A8/

 

entity가 json으로 변환할때..

restController가 리턴하는 엔티티는 messageConverter가 변환한다. json으로 변환 하는 것은 내부적으로 jackson이 사용된다. json infinite recursion jackson이 제공하는 @ 사용법 @JsonIgnore : json으로 변환 안된다. @J

kim-daeyong.github.io

 

'Spring > 오류잡기' 카테고리의 다른 글

@CreationTimestamp 시간 오류  (0) 2021.10.05
Web server failed to start. Port 8080 was already in use.  (0) 2021.07.09

댓글