I'm getting the following Exception with a Spring Data Rest project:
com.fasterxml.jackson.databind.JsonMappingException:
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: org.springframework.data.rest.webmvc.json.["content"]->test.spring.data.rest.xml.entities.Author_$$_jvstb93_1["handler"])
Certainly, I have some entities that have the fetch configuration = FetchType.LAZY.
I followed many instructions and links, but I still have this exception.
What I have already tried to do (with NO effetcs):
add
@EnableHypermediaSupport(type = HypermediaType.HAL)in a config class that extends RepositoryRestMvcConfiguration@Override configureJacksonObjectMapperin the same class, with also usingJackson2DatatypeHelper.configureObjectMapper():@Override protected void configureJacksonObjectMapper(ObjectMapper objectMapper) { objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); Jackson2DatatypeHelper.configureObjectMapper(objectMapper); }add a "
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter" filter in the web.xmlcreate a custom class that
extends ObjectMapper, with this constructor:public HibernateAwareObjectMapper() { Hibernate5Module hm = new Hibernate5Module(); registerModule(hm); }and this config:
<mvc:annotation-driven> <mvc:message-converters> <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> <property name="objectMapper"> <bean class="test.spring.data.rest.xml.config.HibernateAwareObjectMapper" /> </property> </bean> </mvc:message-converters>
No one of the actions above has solved the problem!
How to (definitely) solve this problem?
Thanks.