Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Jaxb2CollectionHttpMessageConverter:explaination+usage?

 
H Paul
Ranch Hand
Posts: 471
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to understand how/when HttpMessageConverter is called to process the request's argument data type.
I try to post List<Computer> with jaxb-annotated Computer.
I expect to be processed by Jaxb2CollectionHttpMessageConverter but it did not happen. Got exception.
My question is am I understanding correctly its usage? (probably no.)
Need some explaination

http://static.springsource.org/spring-framework/docs/3.2.0.M2/reference/html/new-in-3.2.html

In support of this feature, the HttpMessageConverter is extended by GenericHttpMessageConverter adding a method for reading content given a specified parameterized type. The new interface is implemented by the MappingJacksonHttpMessageConverter and also by a new Jaxb2CollectionHttpMessageConverter that can read read a generic Collection where the generic type is a JAXB type annotated with @XmlRootElement or @XmlType.




;





 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not played with this yet. I know it was added in Spring 3.2 are you using the latest version? Take a look at the format of the XML used in the test case.

 
H Paul
Ranch Hand
Posts: 471
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(0. First thing first: thank-you for your dollars Bill.)

I used the latest spring-framework-3.2.1.RELEASE

1. With DEBUGGER, I traced down the exception and found that
By default <mvc:annotation-driven />
does not have/register Jaxb2CollectionHttpMessageConverter. (Wonder why it was not registered by default by design?)
See code 1.

2. So, I did a quick test by programatically registering Jaxb2CollectionHttpMessageConverter. See code 2.
It worked my POST a List because Jaxb2CollectionHttpMessageConverter get called. See TCP/IP mon for the POST+data






 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad you got it working and thanks for posting back with what you figured out!
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!