Yesterday I updated java like posted in the title, now JAXB doesn't parse xml anymore. All objects are simply null, nothing seems to be set.
Given this POJO - ListMatchingProductsResponse
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ListMatchingProductsResponse", propOrder = {
"listMatchingProductsResult",
"responseMetadata"
})
@XmlRootElement(name = "ListMatchingProductsResponse")
public class ListMatchingProductsResponse {
@XmlElement(name = "ListMatchingProductsResult")
private ListMatchingProductsResult listMatchingProductsResult;
@XmlElement(name = "ResponseMetadata")
private ResponseMetadata responseMetadata;
@XmlAttribute(name = "xmlns")
private String xmlns;
public String getXmlns() {
return xmlns;
}
public void setXmlns(String xmlns) {
this.xmlns = xmlns;
}
/**
* Get the value of ListMatchingProductsResult.
*
* @return The value of ListMatchingProductsResult.
*/
public ListMatchingProductsResult getListMatchingProductsResult() {
return listMatchingProductsResult;
}
/**
* Set the value of ListMatchingProductsResult.
*
* @param listMatchingProductsResult The new value to set.
*/
public void setListMatchingProductsResult(ListMatchingProductsResult listMatchingProductsResult) {
this.listMatchingProductsResult = listMatchingProductsResult;
}
/**
* Get the value of ResponseMetadata.
*
* @return The value of ResponseMetadata.
*/
public ResponseMetadata getResponseMetadata() {
return responseMetadata;
}
/**
* Set the value of ResponseMetadata.
*
* @param responseMetadata The new value to set.
*/
public void setResponseMetadata(ResponseMetadata responseMetadata) {
this.responseMetadata = responseMetadata;
}
}
And the ListMatchingProductsResult
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name="ListMatchingProductsResult", propOrder={
"products"
})
@XmlRootElement(name = "ListMatchingProductsResult")
public class ListMatchingProductsResult {
@XmlElement(name="Products")
private ProductList products;
/**
* Get the value of Products.
*
* @return The value of Products.
*/
public ProductList getProducts() {
return products;
}
/**
* Set the value of Products.
*
* @param products
* The new value to set.
*/
public void setProducts(ProductList products) {
this.products = products;
}
/**
* Check to see if Products is set.
*
* @return true if Products is set.
*/
public boolean isSetProducts() {
return products != null;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("products", products)
.toString();
}
}
I use this for unmarshalling:
String s = getResult();
// s is the expected xml string
ListMatchingProductsResponse m = JAXB.unmarshal(new StringReader(s), ListMatchingProductsResponse.class);
log.info(m); // ListMatchingProductsResponse@7164e54
log.info(m.getListMatchingProductsResult()); // null
I'm a bit lost as I don't see any kind of reason for this, nor did I find any changes regarding JAXB in the changelog.
What am I doing wrong here?
The following answers didn't solve my issue so far
JAXB Configuration was broken by upgrading from JDK 1.7 to JDK 1.8 u05 for collections
Unmarshalling jaxB doesn't work, objects null
Unmarshall with JAXB doesn't work
UPDATE
I now have included the following dependency to my project
group: 'org.jvnet.jaxb2.maven2', name: 'maven-jaxb2-plugin', version: '0.13.1'
and it works again. So new question - why is that? Is there something missing / a bug in the 121 java release?