#StackBounty: #java #xml #jaxb #cxf Ignoring undefined element references during unmarshalling in JAXB

Bounty: 100

I’m currently working on a project requesting web services using CXF framework.

For some reasons, I started to receive invalid XML SOAP(missing element with ID referenced from ) response that results in throwing exception during unmarshalling to POJO instance.


XML excerpt where attribute ref references to an element with identifier Person1 that does not exist in XML.

<ext:Applicant s:ref="Person1"/>

where ref is IDREF type in XSD schema

<attribute name="ref" type="IDREF"/>

Exception thrown by JAXB

javax.xml.ws.soap.SOAPFaultException: Unmarshalling Error: Undefined ID "Person1". ] with root cause
javax.xml.bind.UnmarshalException: Undefined ID "Person1".
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:744) ~[jaxb-impl-2.3.1.jar!/:2.3.1]
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.errorUnresolvedIDREF(UnmarshallingContext.java:795) ~[jaxb-impl-2.3.1.jar!/:2.3.1]
    at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$IDREFTransducedAccessorImpl$1.run(TransducedAccessor.java:330) ~[jaxb-impl-2.3.1.jar!/:2.3.1]

Is there a way how to make JAXB ignore missing references and unmarshall incoming XML response without throwing exception?

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.