org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6
- 7
- 8
Issue
- All of the services are implemented as JAX-WS services
- Here's the problem. From time to time the Entity services may require additional elements. We would like to be able to add the additional elements to the entity webservice without impacting the composite webservices that currently use them.
-
We got the following WARNING message in server.log:
2026-01-28 17:09:53,183 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (default task-1) Interceptor for {http://soap.example.gss.redhat.com/}EchoWebServiceService#{http://soap.example.gss.redhat.com/}echo has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element (uri:"", local:"detail"). Expected elements are <{}return> at org.apache.cxf.impl//org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:931) at org.apache.cxf.impl//org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:737) at org.apache.cxf.impl//org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:168) at org.apache.cxf.impl//org.apache.cxf.wsdl.interceptors.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:109) at org.apache.cxf@4.0.5.redhat-00001//org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) at org.apache.cxf@4.0.5.redhat-00001//org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:921) ... Caused by: jakarta.xml.bind.UnmarshalException: unexpected element (uri:"", local:"detail"). Expected elements are <{}return> ... 158 more -
How do I disable XML validation in SOAP client side?
Resolution
- There's a JAXB property you can use to
set-jaxb-validation-event-handlerto resolve this. -
Set this on the client like this:
// for EAP6 and 7 ((javax.xml.ws.BindingProvider) port).getRequestContext().put("set-jaxb-validation-event-handler", false); // For EAP8 or later ((jakarta.xml.ws.BindingProvider) port).getRequestContext().put("set-jaxb-validation-event-handler", false); -
To disable XML validation for all deployed JAX-WS clients, add
<property name="set-jaxb-validation-event-handler" value="false"/>to the webservices subsystem in standalone.xml:<subsystem xmlns="urn:jboss:domain:webservices:2.0" statistics-enabled="${wildfly.webservices.statistics-enabled:${wildfly.statistics-enabled:false}}"> ... <client-config name="Standard-Client-Config"> <property name="set-jaxb-validation-event-handler" value="false"/> <<<=== add this line </client-config> </subsystem> -
The main issue is, the stubs need to be regenerated for the client-side based on the new WSDL that you have on the server-side
When you modified the server and recompiled, the client-side will need to be updated.
Root Cause
- Marshalling errors like this occurs because the WSDL that the client proxies are generated against don't match what just came back from the service (because it's changed since the client was created) and now it doesn't know how to handle the new element.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments