Announcement Announcement Module
Collapse
No announcement yet.
Support for Jackson 2.0 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Support for Jackson 2.0

    When will Spring MVC support Jackson 2.0?

    http://jackson-users.ning.com/profil...2-0-0-released

  • #2
    If you enable the mvc: namespace and Jackson is in the classpath It should be used by default.

    Are you receiving some type of error?

    Comment


    • #3
      Doesn't seem to work when specifying custom ObjectMapper.

      Code:
      	<mvc:annotation-driven>
       		<mvc:message-converters>
      			<bean id="jsonConverter"
      				class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
      				<property name="objectMapper" ref="objectMapper" />
      			</bean>
      		</mvc:message-converters>
      	</mvc:annotation-driven>
      
      	<bean id="objectMapper" class="com.test.webapp.util.HibernateAwareObjectMapper" />
      I get this exception when starting the server.

      Code:
      java.lang.NoClassDefFoundError: org/codehaus/jackson/map/ObjectMapper
      Without <mvc:message-converters>, it works fine.

      Code:
      package com.test.webapp.util;
      
      public class HibernateAwareObjectMapper extends ObjectMapper {
      
      	public HibernateAwareObjectMapper() {
      		Hibernate4Module hm = new Hibernate4Module();
      		registerModule(hm);
      
      		configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
      	}
      
      	public void setPrettyPrint(boolean prettyPrint) {
      		configure(SerializationFeature.INDENT_OUTPUT, prettyPrint);
      	}
      
      }

      Comment


      • #4
        I get the exception when starting the server.

        Code:
        java.lang.NoClassDefFoundError: org/codehaus/jackson/map/ObjectMapper
        But I'm using:

        Code:
        	<bean id="methodHandlerExceptionResolver" class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver">
        		<property name="messageConverters">
        			<list>
        				<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
        			</list>
        		</property>
        	</bean>
        It's because de changing os packages:

        http://wiki.fasterxml.com/JacksonRel..._Java_packages

        Comment


        • #5
          Fun. I guess that means we can't use Jackson 2.0 until Spring 3.2. That's particularly annoying in the case of the jackson-datatype-hibernate4 module, which requires Jackson 2.0.

          Comment


          • #6
            Hello

            I guess that means we can't use Jackson 2.0 until Spring 3.2
            Seems correct, that is a huge problem when third parties changes its API

            I suggest you create a JIRA issue here Spring's Issue Tracker

            Comment


            • #7
              I have JIRA issue created for MappingJacksonJsonView which is in a similar situation as MappingJacksonHttpMessageConverter in.
              https://jira.springsource.org/browse/SPR-9302

              Comment


              • #8
                Hi all,

                I know this thread is a little old, but I just solved using Jackson 2.0 and Spring 3.1.1. My current setup is;

                Spring 3.1.1
                Hibernate 4.1
                Jackson 2.0

                First off, I found this blog post:

                http://blog.pastelstudios.com/2012/0...ule-hibernate/

                Second, I found this tweet:

                https://gist.github.com/2423129

                If you take the file from the tweet, and start from step 2 on the blog post, you should be all set.

                Although not specifically mentioned by the OP, this will also solve the issue of trying to return hibernate entity objects with lazy associations via @ResponseBody and the jackson json mapper, which was my original problem.

                HTH,
                Thantous
                Last edited by thantous; Jun 13th, 2012, 02:17 PM. Reason: Added bit about hibernate

                Comment

                Working...
                X