• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Why does not JAXB bind java.util.Map properly but handles java.util.List  RSS feed

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

Some where I read, in this forum that usage of Collections is not recommended as JAXB will not be knowing how to bind them. So, in order to understand the problem, I started writing a sample code. The code looks as below



So as seen above, I'm trying to see how the binding works for different kinds of object types. I ran the wsgen against the above code, but would end up with the exception



The exception is misleading here, as it sounds as if an Interface can not be used as a return type here. For that matter, List is also an interface and I do not see any issue for List. It is also failing for getDatabase() for the same reason as that of Map.

Using the Interface as the return type is the quite common and also highly respected way of coding. But apparently I'm missing something here to get it work. Can someone point me out the mistake I'm making here and a corrective action.
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This link may help in answering your question a bit

http://weblogs.java.net/blog/2006/06/06/jaxb-and-interfaces
 
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!