JAXB unmarshal results in empty collection April 10, 2012
Posted by kevinbe71 in Java.add a comment
Turned out to be a pretty logical bug… The code was doing this:
@XmlElement(name = “item”)
public List getItemList() {
return _items;
}
public void setItemList(List value) {
_items.clear();
_items.addAll(value);
}
In a simple test this works just fine… And it worked with one JAXB library but not another. Turns out that the unmarshal that wasn’t working was first calling the getter to get the instance of the object, adding items to it, and then calling set! Seems reasonable… But of course this code will break because it will effectively clear the list it is adding to the collection! Fun one to track down…
So, if you think JAXB unmarshalling is not working it may actually be something like this. I eventually found this by putting breakpoints on all the setters to actually verify that JAXB was calling the code and was surprised that it actually was!
GWT Error: “No source code is available for type x.y.z; did you forget to inherit a required module?” December 22, 2011
Posted by kevinbe71 in GWT.add a comment
“No source code is available for type x.y.z; did you forget to inherit a required module?” Check to make sure x.y.z is actually in the “client” package. GWT doesn’t allow you to use java source files from other packages when the code involved is client code- quite logical when you think about it, but the error isn’t that helpful in explaining this!