6 Replies Latest reply on Sep 15, 2010 5:37 PM by Frank Langelage

    NullPointerException calling a WebService

    Frank Langelage Master

      Using JBoss 6.0.0.M4 calling a WebService from a C++-Application using gsoap fails with a NPE:

      23:12:58,293 WARN  [org.apache.cxf.phase.PhaseInterceptorChain] Interceptor for {http://core.ws.fn.mbisoftware.biz/}MessageServiceWS has thrown exception, unwinding now: java.lang.NullPointerException
              at org.apache.cxf.staxutils.StaxUtils.toNextElement(StaxUtils.java:332) [:2.2.10]
              at org.apache.cxf.binding.soap.interceptor.RPCInInterceptor.handleMessage(RPCInInterceptor.java:99) [:2.2.10]
              at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:244) [:2.2.10]
              at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:110) [:2.2.10]
              at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:98) [:2.2.10]
              at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:423) [:2.2.10]
              at org.jboss.wsf.stack.cxf.ServletControllerExt.invoke(ServletControllerExt.java:172) [:3.4.0.Beta2]
              at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:57) [:3.4.0.Beta2]
              at org.jboss.wsf.stack.cxf.transport.ServletHelper.callRequestHandler(ServletHelper.java:162) [:3.4.0.Beta2]
              at org.jboss.wsf.stack.cxf.CXFNonSpringServletExt.invoke(CXFNonSpringServletExt.java:89) [:3.4.0.Beta2]
              at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179) [:2.2.10]
              at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103) [:2.2.10]
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [:1.0.0.Beta2]
              at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159) [:2.2.10]
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:]
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:]
              at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:63) [:]
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:]
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:]
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:]
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:]
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.0.0-SNAPSHOT]
              at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.CR3]
              at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.CR3]
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0-SNAPSHOT]
              at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.0.0-SNAPSHOT]
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:]
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:]
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0-SNAPSHOT]
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:]
              at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0-SNAPSHOT]
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:]
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:]
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [:]
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:]
              at java.lang.Thread.run(Thread.java:619) [:1.6.0_21]

       

      Calling these WebServices from a Java-Application seem to work.

      The code runs OK using JBoss AS 4.24.

       

      Interface:

      @WebService
      @SOAPBinding(style = SOAPBinding.Style.RPC)
      public interface MessageServiceWSI
      {

      ...

      }

       

      Implementation:

      @WebService(endpointInterface = "biz.mbisoftware.fn.ws.core.MessageServiceWSI", serviceName = "MessageServiceWS")
      public class MessageServiceWS implements MessageServiceWSI
      {

      ....

      }

       

      The wsdl-files on JBoss 6 are slightly different to those on 4.24.

      Generating the client artefacts based on the new wsdl files does not change anything.

       

      Any hints?

       

      How can I enable logging to see the incoming message?

        • 1. Re: NullPointerException calling a WebService
          Alessio Soldano Master

          To better understand what's going on we/you should take a look at the exchanged message.

           

          To enable logging with CXF stack, you currently need to leverages the Apache CXF means of message logging. This basically implies either using the LoggingFeature or setting the logging interceptors into the bus. See the doc here.

          In short, if you're using Spring on the application server, currently the easiest way is to either modify the provided jbossws-cxf.xml descriptor or enable logging for all endpoints. If you're not using Spring, you need to use the programmatic API, see org.jboss.test.ws.jaxws.cxf.logging tests.

          • 2. Re: NullPointerException calling a WebService
            Frank Langelage Master

            I  enabled logging:

            ----------------------------
            ID: 1
            Address: /mbi-ws/mbi2e-lafr-sb2000-ipc/common/VersionWS
            Encoding: ISO-8859-1
            Content-Type:
            Headers: {connection=[close], host=[sb2000:8080], transfer-encoding=[chunked], SOAPAction=[""], user-agent=[gSOAP/2.7], Content-Type=[null]}
            Payload: <?xml version="1.0" encoding="UTF-8"?>
            <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://common.ws.fn.mbisoftware.biz/"><SOAP-ENV:Body><ns1:getVersionAsXml></ns1:getVersionAsXml></SOAP-ENV:Body></SOAP-ENV:Envelope>
            --------------------------------------
            23:25:54,831 WARN  [org.apache.cxf.phase.PhaseInterceptorChain] Interceptor for {http://common.ws.fn.mbisoftware.biz/}VersionWS has thrown exception, unwinding now: java.lang.NullPointerException
                    at org.apache.cxf.staxutils.StaxUtils.toNextElement(StaxUtils.java:332) [:2.2.10]
                    at org.apache.cxf.binding.soap.interceptor.RPCInInterceptor.handleMessage(RPCInInterceptor.java:99) [:2.2.10]
                    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:244) [:2.2.10]
                    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:110) [:2.2.10]
                    at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:98) [:2.2.10]
                    at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:423) [:2.2.10]
                    at org.jboss.wsf.stack.cxf.ServletControllerExt.invoke(ServletControllerExt.java:172) [:3.4.0.Beta2]
                    at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:57) [:3.4.0.Beta2]
                    at org.jboss.wsf.stack.cxf.transport.ServletHelper.callRequestHandler(ServletHelper.java:162) [:3.4.0.Beta2]
                    at org.jboss.wsf.stack.cxf.CXFNonSpringServletExt.invoke(CXFNonSpringServletExt.java:89) [:3.4.0.Beta2]
                    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179) [:2.2.10]
                    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103) [:2.2.10]
                    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [:1.0.0.Beta2]
                    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159) [:2.2.10]
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:]
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:]
                    at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:63) [:]
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:]
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:]
                    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:]
                    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:]
                    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.0.0-SNAPSHOT]
                    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.CR3]
                    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.CR3]
                    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0-SNAPSHOT]
                    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.0.0-SNAPSHOT]
                    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:]
                    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:]
                    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0-SNAPSHOT]
                    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:]
                    at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0-SNAPSHOT]
                    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:]
                    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:]
                    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [:]
                    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:]
                    at java.lang.Thread.run(Thread.java:619) [:1.6.0_21]

             

            23:25:54,975 INFO  [org.apache.cxf.interceptor.LoggingOutInterceptor] Outbound Message
            ---------------------------
            ID: 1
            Response-Code: 500
            Encoding: ISO-8859-1
            Content-Type: text/xml
            Headers: {}
            Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Fault occurred while processing.</faultstring></soap:Fault></soap:Body></soap:Envelope>

            --------------------------------------

             

            The interface is:

            @WebService
            @SOAPBinding(style = SOAPBinding.Style.RPC)
            public interface VersionWSI
            {
                 VersionResponse getVersion();

                 ServiceStringResponse getVersionAsXml();

                 ServiceStringResponse getProjectShortName();

                 ServiceStringResponse getDefaultCurrency();
            }

             

            Using the java client the webservice call succeeds:

            ----------------------------
            ID: 2
            Address: /mbi-ws/mbi2e-lafr-sb2000-ipc/common/VersionWS
            Encoding: UTF-8
            Content-Type: text/xml; charset=UTF-8
            Headers: {cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[sb2000:8080], Content-Length=[191], SOAPAction=[""], user-agent=[Apache CXF 2.2.10], Content-Type=[text/xml; charset=UTF-8], Accept=[*/*], pragma=[no-cache]}
            Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:getVersion xmlns:ns1="http://common.ws.fn.mbisoftware.biz/"></ns1:getVersion></soap:Body></soap:Envelope>
            --------------------------------------
            23:32:03,824 INFO  [org.apache.cxf.interceptor.LoggingOutInterceptor] Outbound Message
            ---------------------------
            ID: 2
            Encoding: UTF-8
            Content-Type: text/xml
            Headers: {}
            Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:getVersionResponse xmlns:ns1="http://common.ws.fn.mbisoftware.biz/"><return><errorCode>SUCCESS</errorCode><compiler>g++32</compiler><config><configNo>2</configNo><configText>ohne Lizenzserver</configText><validDate>99999999</validDate></config>

            <release>Entwicklungsstand</release><session>11308 / 11310</session><sys>sparc58-i350UC3</sys><uname>SunOS sb2000 5.10 Generic_142900-15 sun4u sparc SUNW,Sun-Blade-1000</uname><version>3.4.6.0291</version></return></ns1:getVersionResponse></soap:Body></soap:Envelope>
            --------------------------------------

            • 3. Re: NullPointerException calling a WebService
              Jim Ma Apprentice

              Did you see any difference in the server inbound message between the C++ gsoap client and java application client ? What did you change in wsdl files on JBoss6 ?

              • 4. Re: NullPointerException calling a WebService
                Frank Langelage Master

                I could not see any relevant difference for the message itself.

                The header content is different and diffrences on Encoding and Content-Type,

                The gsoap version declares all namespaces, including some additional ones, on the soap:envelope tag with different names for the soap namespaces.

                It's the same java code implementing our webservices for both servers, JBoss 4.24 and 6.0.0.M4 (source of current trunk checked out and compiled).

                So the difference in the wsdl files I mentioned comes from the different webservice implementation used (jbossws-3.0.1-native.2.0.4.GA and jbossws-cxf-3.4.0.Beta2).

                 

                ID: 1
                Address: /mbi-ws/mbi2e-lafr-sb2000-ipc/common/VersionWS
                Encoding: ISO-8859-1
                Content-Type:
                Headers:  {

                connection=[close],

                Content-Type=[null]

                host=[sb2000:8080],

                transfer-encoding=[chunked],

                SOAPAction=[""],

                user-agent=[gSOAP/2.7],

                }

                Payload:

                <?xml version="1.0" encoding="UTF-8"?>
                <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://common.ws.fn.mbisoftware.biz/">

                <SOAP-ENV:Body>

                <ns1:getVersionAsXml></ns1:getVersionAsXml>

                </SOAP-ENV:Body>

                </SOAP-ENV:Envelope>

                 

                ID: 2
                Address: /mbi-ws/mbi2e-lafr-sb2000-ipc/common/VersionWS
                Encoding: UTF-8
                Content-Type: text/xml; charset=UTF-8
                Headers:  {

                Accept=[*/*],

                cache-control=[no-cache],

                connection=[keep-alive],

                Content-Length=[191],

                Content-Type=[text/xml;  charset=UTF-8],

                content-type=[text/xml; charset=UTF-8],

                host=[sb2000:8080],

                SOAPAction=[""],

                user-agent=[Apache CXF 2.2.10],

                pragma=[no-cache]

                }
                Payload:

                <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

                <soap:Body>

                <ns1:getVersion xmlns:ns1="http://common.ws.fn.mbisoftware.biz/">

                </ns1:getVersion>

                </soap:Body>

                </soap:Envelope>

                • 5. Re: NullPointerException calling a WebService
                  Jim Ma Apprentice

                  Looks like it is caused by the gsoap chunk mode.  Can you disable the chunk mode in gsoap?

                  • 6. Re: NullPointerException calling a WebService
                    Frank Langelage Master

                    Yes, I disabled the chunked mode and no NPE anymore.

                    Thank you for your support.

                    I don't know why we enabled this, but I think for now that we can live without this.