Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-3925

WebFaultOutInterceptor expects the Fault.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.4
    • 2.3.8, 2.4.5, 2.5.1
    • JAX-WS Runtime
    • None
    • Unknown

    Description

      WebFaultOutInterceptor reports NullPointerException when message content doesn't contains Exception.

      I was trying to create custom interceptor to transform SoapFault to SoapMessage (read more) and when I registered interceptor like:

      InternalActServiceFaultOutInterceptor.java
      public class InternalActServiceFaultOutInterceptor extends
      		AbstractSoapInterceptor {
      
      	public InternalActServiceFaultOutInterceptor() {
      		super(Phase.PRE_STREAM);
      
      		addBefore(Arrays.asList(StaxOutInterceptor.class.getName(), AttachmentOutInterceptor.class.getName()));
      	}
      
      	@Override
      	public void handleMessage(SoapMessage soapMessage) throws Fault {
      		Exception exception = soapMessage.getContent(Exception.class);
      		if (exception != null) {
      			soapMessage.getExchange().put(Exception.class, null);
      
      			for (Class<?> contentFormat : soapMessage.getContentFormats()) {
      				soapMessage.setContent(contentFormat, null);
      			}
      
      			soapMessage.setContent(List.class, new MessageContentsList(createSoapMessage(RegisterDocumentResponse.class)));
      		}
      	}
      
      	private <T> RegisterDocumentResponse createSoapMessage(Class<T> messageType) {
      		RegisterDocumentResponse response = new RegisterDocumentResponse();
      		response.setStatus(ServiceStatusType.SUCCESS);
      
      		return response;
      	}
      }
      

      I saw:

      WARN  [http-8080-1][,,][PhaseInterceptorChain.doLog()] Interceptor for {http://...}InternalActServiceImplService#{http://...}registerDocument has thrown exception, unwinding now
      java.lang.NullPointerException
      	at org.apache.cxf.jaxws.interceptors.WebFaultOutInterceptor.handleMessage(WebFaultOutInterceptor.java:83)
      	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
      	at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:105)
      	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:323)
      	at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
      	at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:206)
      	at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:218)
      	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:200)
      	at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:114)
      	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:184)
      	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:107)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      

      It's all because WebFaultOutInterceptor expecting in line 83 Fault in message.

      Attachments

        Activity

          People

            dkulp Daniel Kulp
            michal.mech MichaƂ Mech
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: