Getting list <String> from XML using JAXB (Moxy)

I am using jdk1.6 and eclipselink-2.3.2.v20111125-r10461

I have XML similar to:




My annotated bean looks like this:

@XmlRootElement(name = "alpha")
public Class Alpha {

    private String omegaValue;

    @XmlElement(name = "delta")
    @XmlElementWrapper(name = "gamma")
    private List<String> deltaList;

    public String getOmegaValue() {
        return omegaValue;

    public void setOmegaValue(String omegaValue) {
        this.omegaValue = omegaValue;

    public List<String> getDeltaList() {
        return deltaList;

    public void setDeltaList (List<String> deltaList ) {
        this.deltaList = deltaList ;



in my test code i do the following to check the list but it is empty.

System.out.println(alphaInstance.getDeltaList().size());//returns 0!!
for (String deltaValue: alphaInstance.getDeltaList()) {//empty!!



Is there something wrong here? OmegaValue works great. Please help, thanks.


source to share

1 answer

Your mapping for the property is deltaList

missing a beta level. You can use annotation @XmlPath

and do the following:

private List<String> deltaList;


Additional Information



All Articles