<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Continuing problem with XTS WS-T tests in AS trunk/CXF 2.2.9
</h3>
<span style="margin-bottom: 10px;">
reply from <a href="http://community.jboss.org/people/adinn">Andrew Dinn</a> in <i>JBoss Web Services CXF</i> - <a href="http://community.jboss.org/message/548969#548969">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><blockquote class="jive-quote"><p>'ll follow up with progress on the results of making the changes I described above.</p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Hmm, more regress than progress I am afraid.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The latest CXF stack wil dispatch from the client end the soap fault I am sending via the SoapFaultService . However, it will not deliver the fault to the target endpoint. This is not because the endpoint is masquerading as a SoapFaultService. Even if I were to install a pucker endpoint defined by my SoapFault service WSDL the current CXF would not deliver the message. Th eproblme is that the incoming message is actually a SoapFault and the incoming message chain assumes, invalidly, that it must relate to an outgoing request and ends up tripping over its own knickers with a null pointer exception.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The message gets received and routed to the relevant endpoint handler. Here is the stack trace for the exception which is causing mesage deliver to blow up:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><blockquote class="jive-quote"><p><span style="font-family: courier new,courier;">java.lang.NullPointerException<br/>    at org.apache.cxf.interceptor.InFaultChainInitiatorObserver.addToChain(InFaultChainInitiatorObserver.java:62)<br/>    at org.apache.cxf.interceptor.InFaultChainInitiatorObserver.initializeInterceptors(InFaultChainInitiatorObserver.java:59)<br/>    at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:95)<br/>    at org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor.handleMessage(SOAPHandlerInterceptor.java:142)<br/>    at org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor.handleMessage(SOAPHandlerInterceptor.java:71)<br/>    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243)<br/>    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:110)<br/>    at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:98)<br/>    at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:423)<br/>    at org.jboss.wsf.stack.cxf.ServletControllerExt.invoke(ServletControllerExt.java:172)<br/>    at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:57)<br/>    at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:130)<br/>    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)<br/>    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103)<br/>    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)<br/>    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)<br/>    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324)<br/>    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)<br/>    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)<br/>    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)<br/>    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181)<br/>    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285)<br/>    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261)<br/>    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88)<br/>    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:93)<br/>    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)<br/>    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)<br/>    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)<br/>    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)<br/>    at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53)<br/>    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)<br/>    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)<br/>    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)<br/>    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)<br/>    at java.lang.Thread.run(Thread.java:619)</span></p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>So, things go all right up to the point where the <span style="font-family: courier new,courier;">SOAPHandlerInterceptor.handleMessage</span> gets invoked. It calls <span style="font-family: courier new,courier;">handleMessageInternal</span> which calls <span style="font-family: courier new,courier;">createProtocolMessageContext</span>. The latter looks for incoming reference parameters and then checks to see if the message body contains a soap fault.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><blockquote class="jive-quote"><span style="font-family: courier new,courier;">protected MessageContext createProtocolMessageContext(SoapMessage message) {<br/>        SOAPMessageContextImpl sm = new SOAPMessageContextImpl(message);<br/>        <br/>        Exchange exch = message.getExchange();<br/>        setupBindingOperationInfo(exch, sm);<br/>        SOAPMessage msg = sm.getMessage();<br/>        try {            <br/>            List<SOAPElement> params = new ArrayList<SOAPElement>();<br/>            message.put(MessageContext.REFERENCE_PARAMETERS, params);<br/>            SOAPHeader head = msg.getSOAPHeader();<br/>            if (head != null) {<br/>                Iterator<Node> it = CastUtils.cast(head.getChildElements());<br/>                while (it != null && it.hasNext()) {<br/>                    Node nd = it.next();<br/>                    if (nd instanceof SOAPElement) {<br/>                        SOAPElement el = (SOAPElement)nd;<br/>                        if (el.hasAttributeNS(Names.WSA_NAMESPACE_NAME, "IsReferenceParameter")<br/>                            && ("1".equals(el.getAttributeNS(Names.WSA_NAMESPACE_NAME,<br/>                                                             "IsReferenceParameter"))<br/>                                || Boolean.parseBoolean(el.getAttributeNS(Names.WSA_NAMESPACE_NAME,<br/>                                                                          "IsReferenceParameter")))) {<br/>                            params.add(el);<br/>                        }<br/>                    }<br/>                }<br/>            }<br/>            if (msg.getSOAPPart().getEnvelope().getBody() != null <br/>                && msg.getSOAPPart().getEnvelope().getBody().hasFault()) {<br/>                return null;<br/>            }            <br/>        } catch (SOAPException e) {<br/>            throw new Fault(e);<br/>        }<br/>        <br/>        <br/>        return sm;<br/>    }</span> <br/></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Since the incoming message is indeed a soap fault it returns null rather than a soap message context. Now this would be appropriate if the message was a fault being delivered as part of a RPC MEP or on the outbound side of a OneWay MEP exchange indicating a delivery problem. However, this is not the case. This fault is the payload of an incoming OneWay MEP message.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Because <span style="font-family: courier new,courier;">createProtocolMessageContext</span> returns <span style="font-family: courier new,courier;">null</span> <span style="font-family: courier new,courier;">handleMessageInternal</span> returns true without processing the message any further.</p><blockquote class="jive-quote"><span style="font-family: courier new,courier;">private boolean handleMessageInternal(SoapMessage message) {<br/>        <br/>    MessageContext context = createProtocolMessageContext(message);<br/>    if (context == null) {<br/>        return true;<br/>    }<br/>    . . .</span><br/></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-family: courier new,courier;">handleMessage</span> goes on to set up an <span style="font-family: courier new,courier;">XMLStreamReader</span> on the <span style="font-family: courier new,courier;">SOAPMessage</span> and runs <span style="font-family: courier new,courier;">SAAJInterceptor.replaceHeaders</span> as per any incoming message and then, because it assumes this is a fault rather than a normal payload, aborts the current interceptor chain and runs the endpoint's incoming fault observer <span style="font-family: courier new,courier;">onMessage</span> routine which is where we enter the exception stack trace shown above.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><blockquote class="jive-quote"><p><span style="font-family: courier new,courier;">    public void handleMessage(SoapMessage message) {<br/>        if (binding.getHandlerChain().isEmpty()) {<br/>            return;<br/>        }<br/>        if (getInvoker(message).getProtocolHandlers().isEmpty()) {<br/>            return;<br/>        }<br/><br/>        checkUnderstoodHeaders(message);<br/><br/>        if (getInvoker(message).isOutbound()) {<br/>            if (!chainAlreadyContainsSAAJ(message)) {<br/>                SAAJ_OUT.handleMessage(message);<br/>            }<br/>            message.getInterceptorChain().add(ending);<br/>        } else {<br/>            boolean isFault = handleMessageInternal(message);<br/>            SOAPMessage msg = message.getContent(SOAPMessage.class);<br/>            if (msg != null) {<br/>                XMLStreamReader xmlReader = createXMLStreamReaderFromSOAPMessage(msg);<br/>                message.setContent(XMLStreamReader.class, xmlReader);<br/>                // replace headers<br/>                try {<br/>                    SAAJInInterceptor.replaceHeaders(msg, message);<br/>                } catch (SOAPException e) {<br/>                    e.printStackTrace();<br/>                }<br/>            }<br/>            if (isFault) {<br/>                Endpoint ep = message.getExchange().get(Endpoint.class);<br/>                message.getInterceptorChain().abort();<br/>                if (ep.getInFaultObserver() != null) {<br/>                    ep.getInFaultObserver().onMessage(message);<br/>                    <br/>                }<br/>            }<br/>        }<br/>    }<br/></span></p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The observer is an <span style="font-family: courier new,courier;">InFaultChainInitiatorObserver</span> whose onMessage method is inherited from super <span style="font-family: courier new,courier;">AbstractFaultChainInitiatorObserver</span>. This runs to the point where it calls <span style="font-family: courier new,courier;">initializeInterceptors</span> which eventually calls <span style="font-family: courier new,courier;">addToChain</span>. The null pointer exception happens here</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><blockquote class="jive-quote"><p><span style="font-family: courier new,courier;">private void addToChain(PhaseInterceptorChain chain, Message m) {<br/>        Collection<InterceptorProvider> providers <br/>            = CastUtils.cast((Collection<?>)m.get(Message.INTERCEPTOR_PROVIDERS)); // <= blow up!<br/>        if (providers != null) {<br/>            for (InterceptorProvider p : providers) {<br/>                chain.add(p.getInFaultInterceptors());<br/>            }<br/>        }<br/>        Collection<Interceptor> is = CastUtils.cast((Collection<?>)m.get(Message.FAULT_IN_INTERCEPTORS));<br/>        if (is != null) {<br/>            chain.add(is);<br/>        }<br/>    }</span></p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>It appears that <span style="font-family: courier new,courier;">m.get(Message.INTERCEPTOR_PROVIDERS)</span> returns <span style="font-family: courier new,courier;">null</span>. I cannot actually find any place in the CXF source where this value is ever put so I don't really know if this is the only thing which is wrong. Anyway, I think the fact that we have now switched to fautl processing rather than delivering an incoming fault message is the root cause of the problem here. I think <span style="font-family: courier new,courier;">createProtocolMessageContext</span> needs to be changed as follows:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><blockquote class="jive-quote"><pre jivemacro="quote"><span style="font-family: courier new,courier;">    protected MessageContext createProtocolMessageContext(SoapMessage message) {<br/>        SOAPMessageContextImpl sm = new SOAPMessageContextImpl(message);<br/>        . . .<br/>            if (msg.getSOAPPart().getEnvelope().getBody() != null <br/>                && msg.getSOAPPart().getEnvelope().getBody().hasFault()<br/>                && !(isRequestor(msg) && isInbound())) { // <== allow incoming fault request<br/>                return null;<br/>            }            <br/>        } catch (SOAPException e) {<br/>            throw new Fault(e);<br/>        }<br/>        <br/>        <br/>        return sm;<br/>    } </span></pre>
</blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Sorry but I'm going to have to raise a Blocker JIRA for this on Jonathan's instructions. It is not possible for the update to CXF to go out in the product if it breaks XTS -- at least not without a decision from on high.</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/548969#548969">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Web Services CXF at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2046">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>