Announcement Announcement Module
Collapse
No announcement yet.
Spring 3.0.5 compatible w/ Jackson 1.6? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring 3.0.5 compatible w/ Jackson 1.6?

    This is regarding pojo->JSON serialization on Spring 3.0.5 with Jackson 1.0.1 and with circular references in my hibernate hbm xmls. My controller method is annotated with @ResponseBody and returns the pojo. The app's configured such that the returned object is serialized into JSON. Spring uses Jackson to do so. On response, I'm incurring the JsonMappingException as included below. I suspect the issue is with the circular references inherent to my entities and as defined in my hibernate hbm xmls. I see Jackson v1.6 was released in Sept and includes a nice annotation set that would help the circ refs but, sadly, Spring 3.0.5 isn't compatible with it.

    How can I configure this version of Jackson (v1.0.1) on Spring 3.0.5 to cut off the look-back in bidirectional references?


    Code:
    08:31:19,507 [http-8080-1] DEBUG DispatcherServlet  Could not complete request
    org.codehaus.jackson.map.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer (and no bean properties discovered to create bean serializer)
    	at org.codehaus.jackson.map.ser.StdSerializerProvider$1.serialize(StdSerializerProvider.java:53)
    	at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:91)
    	at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:52)
    	at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:91)
    	at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:52)
    	at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serialize(ContainerSerializers.java:66)
    	at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serialize(ContainerSerializers.java:32)
    	at org.codehaus.jackson.map.ser.ContainerSerializers$MapSerializer.serialize(ContainerSerializers.java:275)
    	at org.codehaus.jackson.map.ser.ContainerSerializers$MapSerializer.serialize(ContainerSerializers.java:233)
    	at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:91)
    	at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:52)
    	at org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.java:225)
    	at org.codehaus.jackson.map.ser.StdSerializerProvider.serializeValue(StdSerializerProvider.java:206)
    	at org.codehaus.jackson.map.ObjectMapper.writeValue(ObjectMapper.java:341)
    	at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.writeInternal(MappingJacksonHttpMessageConverter.java:153)
    	at org.springframework.http.converter.AbstractHttpMessageConverter.write(AbstractHttpMessageConverter.java:181)
    	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.writeWithMessageConverters(AnnotationMethodHandlerAdapter.java:975)
    	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.handleResponseBody(AnnotationMethodHandlerAdapter.java:933)
    	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.getModelAndView(AnnotationMethodHandlerAdapter.java:882)
    	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:428)
    	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
    	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    	at java.lang.Thread.run(Thread.java:619)
    All help very much appreciated!
    Last edited by sfrancolla; Nov 25th, 2010, 08:32 AM.

  • #2
    You can use Jackson's Annotation support in your Domain objects.

    Jackson Annotation Guide

    In particular, look at @JsonManagedReference, @JsonBackReference and @JsonIgnore.

    Comment

    Working...
    X