• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Jaxb2CollectionHttpMessageConverter:explaination+usage?

 
Ranch Hand
Posts: 491
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.





;





 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 491
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad you got it working and thanks for posting back with what you figured out!
 
Once upon a time there were three bears. And they were visted by a golden haired tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic