Results 1 to 8 of 8

Thread: Support for Jackson 2.0

  1. #1
    Join Date
    Mar 2011
    Posts
    4

    Default Support for Jackson 2.0

    When will Spring MVC support Jackson 2.0?

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

  2. #2
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,791

    Default

    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?
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  3. #3
    Join Date
    Oct 2009
    Posts
    5

    Default

    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);
    	}
    
    }

  4. #4
    Join Date
    Mar 2011
    Posts
    4

    Default

    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

  5. #5
    Join Date
    Oct 2009
    Posts
    5

    Default

    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.

  6. #6
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,791

    Default

    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
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  7. #7
    Join Date
    Dec 2010
    Posts
    1

    Default

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

  8. #8
    Join Date
    Jun 2011
    Posts
    3

    Default

    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 at 01:17 PM. Reason: Added bit about hibernate

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •