wood burning stoves*
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes Why does not JAXB bind java.util.Map properly but handles java.util.List Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "Why does not JAXB bind java.util.Map properly but handles java.util.List" Watch "Why does not JAXB bind java.util.Map properly but handles java.util.List" New topic
Author

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

Ravi C Kota
Ranch Hand

Joined: Jan 29, 2008
Posts: 61
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.


Thanks & Regards, Ravi C.Kota
SCJP 5.0, OCDJWS 5.0
Rajkishore Pujari
Ranch Hand

Joined: Sep 03, 2005
Posts: 46
This link may help in answering your question a bit

http://weblogs.java.net/blog/2006/06/06/jaxb-and-interfaces
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Why does not JAXB bind java.util.Map properly but handles java.util.List
 
Similar Threads
How to Serialize Maps?
Problem getting attributes from request in Struts2
How to retrieve metadata in ibatis
Errata on HF question?
Cannot get new screen to work properly; similar screen was recently added successfully