Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-7895

Custom message converters registered with AnnotationMethodHandlerAdapter are not used, only the default ones are used.

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Invalid
    • Affects Version/s: 3.0.5
    • Fix Version/s: None
    • Component/s: OXM
    • Labels:
      None

      Description

      Custom message converters registered with AnnotationMethodHandlerAdapter are not used, only the default ones registered with <mvc:annotation-driven /> are used. I found that the setMessageConverters() method of AnnotationMethodHandlerAdapter class is called two times, one for the default and another one for the bean defined in the spring xml file. The one defined in the spring xml file is never used when doing actual marshalling and unmarshalling.

      For example the following jibx message converter is not used:

      <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
      <property name="messageConverters">
      <util:list id="beanList">
      <ref bean="marshallingHttpMessageConverter" />
      </util:list>
      </property>

      </bean>

      <bean id="marshallingHttpMessageConverter" class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
      <constructor-arg ref="jixbUserMarshaller" />
      <property name="supportedMediaTypes" value="text/xml" />
      </bean>

      <oxm:jibx-marshaller id="jixbUserMarshaller" target-class="com.company.restpoc.model.User" />

      In my opinion the jibx support in Spring OXM is rather poor. We need to define a separate converter for each target-class. We don't need to do that kind of thing when using Jersey with Jibx. We just need two @Provider classes that implement MessageBodyReader and MessageBodyWriter. I have attached JIBXBodyReader and JIBXBodyWriter for your reference.

        Attachments

          Activity

            People

            • Assignee:
              rstoya05-aop Rossen Stoyanchev
              Reporter:
              adeveloper Jack Woods
              Last updater:
              Trevor Marshall
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                7 years, 14 weeks, 5 days ago