JAXB marshalling issues

Invalid content was found starting with element 'xxx:xxx'. One of '{"xxx":xxx}' is expected

Interceptor for {http://www.xxx.nl/xxx/service}xxx#{http://www.xxx.nl/xxx/service}xxx has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Marshalling Error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'erf:DierSoort'. One of '{"http://www.xxx.nl/xxx":OrgaanParentCode}' is expected.
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:266) ~[cxf-rt-databinding-jaxb-3.1.3.jar:3.1.3]

In my case the problem was this:

    @XmlElement(name = "OrgaanParentCode", namespace = "http://www.xxx.nl/xxx", required = true)
    public String getOrgaanParentCode() {
        if (parent == null) return null;
        return parent.getOrgaanCode();
    }

"required=true" means that no 'null' should be returned as this leads to an empty and discarded ellement. Setting required to false fixed the issue. Returning "" instead of null also fixes the problem.