[SWS-857] NullPointerException: empty SOAP body and use of an interceptor Created: 07/Jan/14  Updated: 20/Mar/14  Resolved: 27/Jan/14

Status: Resolved
Project: Spring Web Services
Component/s: Core
Affects Version/s: 2.1.4
Fix Version/s: 2.2.RC1

Type: Bug Priority: Major
Reporter: Martin Wegner Assignee: Arjen Poutsma
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

What you need:
1.) An endpoint with SOAP action mapping and payload root mapping.
2.) An interceptor for the payload root mapping.

When you send a message with a SOAP action and an empty SOAP body, then you will get a null pointer exception.

Problem is in PayloadRootSmartSoapEndpointInterceptor line 61/62:

QName payloadRootName = PayloadRootUtils.getPayloadRootQName(request.getPayloadSource(), transformerHelper);
if (!namespaceUri.equals(payloadRootName.getNamespaceURI())) {

The variable payloadRootName is null if the SOAP body is empty.

Stack trace (the NullPointerException is logged at DEBUG level...):
DEBUG o.s.w.s.s.SoapMessageDispatcher MessageDispatcher.processEndpointException:333 - Endpoint invocation resulted in exception - responding with Fault
java.lang.NullPointerException: null
	at org.springframework.ws.soap.server.endpoint.interceptor.PayloadRootSmartSoapEndpointInterceptor.shouldIntercept(PayloadRootSmartSoapEndpointInterceptor.java:62) ~[spring-ws-2.1.4.RELEASE-all.jar:2.1.4.RELEASE]
	at org.springframework.ws.server.endpoint.interceptor.DelegatingSmartEndpointInterceptor.shouldIntercept(DelegatingSmartEndpointInterceptor.java:61) ~[spring-ws-2.1.4.RELEASE-all.jar:2.1.4.RELEASE]
	at org.springframework.ws.server.endpoint.mapping.AbstractEndpointMapping.getEndpoint(AbstractEndpointMapping.java:139) ~[spring-ws-2.1.4.RELEASE-all.jar:2.1.4.RELEASE]
	at org.springframework.ws.server.MessageDispatcher.getEndpoint(MessageDispatcher.java:269) [spring-ws-2.1.4.RELEASE-all.jar:2.1.4.RELEASE]
	at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:212) [spring-ws-2.1.4.RELEASE-all.jar:2.1.4.RELEASE]
	at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:173) [spring-ws-2.1.4.RELEASE-all.jar:2.1.4.RELEASE]
	at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:88) [spring-ws-2.1.4.RELEASE-all.jar:2.1.4.RELEASE]
	at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:59) [spring-ws-2.1.4.RELEASE-all.jar:2.1.4.RELEASE]
	at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:292) [spring-ws-2.1.4.RELEASE-all.jar:2.1.4.RELEASE]
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:931) [spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:833) [spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) [servlet-api.jar:na]
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:807) [spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) [servlet-api.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) [catalina.jar:7.0.47]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.47]
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) [tomcat7-websocket.jar:7.0.47]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) [catalina.jar:7.0.47]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.47]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) [catalina.jar:7.0.47]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) [catalina.jar:7.0.47]
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:611) [catalina.jar:7.0.47]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) [catalina.jar:7.0.47]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) [catalina.jar:7.0.47]
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) [catalina.jar:7.0.47]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) [catalina.jar:7.0.47]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) [catalina.jar:7.0.47]
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) [tomcat-coyote.jar:7.0.47]
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) [tomcat-coyote.jar:7.0.47]
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2430) [tomcat-coyote.jar:7.0.47]
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2419) [tomcat-coyote.jar:7.0.47]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.7.0_45]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.7.0_45]
	at java.lang.Thread.run(Unknown Source) [na:1.7.0_45]


Generated at Sun Dec 17 02:14:57 UTC 2017 using JIRA 6.4.14#64029-sha1:ae256fe0fbb912241490ff1cecfb323ea0905ca5.