Announcement Announcement Module
Collapse
No announcement yet.
Jackson2 & JAXB AnnotationIntrospector not working as expected Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Jackson2 & JAXB AnnotationIntrospector not working as expected

    Hi - I'm trying to get JAXB Annotations working with the latest spring and jackson binaries. Configuration and versions below.

    The issue seems to be that JAXB annotations are completely ignore if I include the Jackson AnnotationIntrospector (even as secondary pair). If I only include the JAXB AnnotationIntrospector all works as expected. This worked in previous versions of spring (pre 3 and jackson 1) but seems to be broken in the latest versions.

    - Spring 3.2.1
    - Jackson 2.1.3

    Code:
    	<!-- JSR-303 support will be detected on classpath and enabled automatically -->
        <mvc:annotation-driven content-negotiation-manager="contentNegotiationManager">
        	 <mvc:message-converters>
        	 	<bean id="jacksonMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
            		<property name="objectMapper" ref="jacksonObjectMapper" />
     			</bean>
        	</mvc:message-converters>
        </mvc:annotation-driven>
        
        <!-- JAXB/JSON Setup -->
        <bean id="jacksonObjectMapper" class="com.fasterxml.jackson.databind.ObjectMapper">
        	<property name="annotationIntrospector" ref="pairedAnnotationIntrospector" />
    	</bean>
        
        <bean id="pairedAnnotationIntrospector" class="com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair"  factory-method="create">
        	<constructor-arg ref="jaxbAnnotationIntrospector" />   
    		<constructor-arg ref="jacksonAnnotationIntrospector" />		   
    	</bean>   
        <bean id="jaxbAnnotationIntrospector" class="com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector" />
        <bean id="jacksonAnnotationIntrospector" class="com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector" />
    
    
    <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
    		<property name="viewResolvers">
    			<list>
    				<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    					<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>    
    					<property name="prefix" value="/tiles/"/>
    					<property name="suffix" value=".jsp"/>
    					<property name="order" value="3"/>
    				</bean>
    			</list>
    		</property>
    		<property name="defaultViews">
    			<list>
    				<bean id="jacksonView" class="org.springframework.web.servlet.view.json.MappingJackson2JsonView">
        				<property name="objectMapper" ref="jacksonObjectMapper" />
        			</bean>
    				<bean class="org.springframework.web.servlet.view.xml.MarshallingView">					
    					<property name="marshaller">
    						<oxm:jaxb2-marshaller id="jaxb2Marshaller">	   		
       							<oxm:class-to-be-bound name="au.com.mymodel.Config" />	
    						</oxm:jaxb2-marshaller>
                        </property>
                    </bean>
    			</list>
    		</property>
    	</bean>

  • #2
    I have the exact same problem today (Mar 2014) after 1 year and can't believe it's still a bug. Is there anything you found out on this since alvins? Anyone else?

    Comment

    Working...
    X