NullPointer exception returned Web Service - problem decoding envelope
832942Jan 20 2011 — edited Oct 7 2011Hi Folks,
I'm fairly new to Java/Glassfish so any help would be greatly appreciated.
I am trying to build a simple proof of concept web service that accepts 2 strings (as complexType) and returns the same two strings (as complexType). The end goal is to build an integration bridge between 2 applications, one of which exposes a java api and the other which does not have direct java integration abilities but can call web services.
I'm using Netbeans 6.5 & Glassfish 2.1.1 on top of jdk1.5
The web service seems to work fine when called from a java client, .net client or from soapUI, however when I try to call it from the app I'm trying to integrate with, I get an http 500 return from glassfish (which I captured with fiddler) as shown below:
The app that fails calling the web service uses axis1.1
----------------------------------------
HTTP/1.1 500 Internal Server Error
X-Powered-By: Servlet/2.5
Server: Sun GlassFish Enterprise Server v2.1.1
Content-Type: text/xml;charset="utf-8"
Content-Length: 8006
Date: Tue, 18 Jan 2011 19:17:10 GMT
Connection: close
<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><S:Fault xmlns:ns3="http://www.w3.org/2003/05/soap-envelope"><faultcode>S:Server</faultcode><faultstring>java.lang.NullPointerException</faultstring><detail><ns2:exception xmlns:ns2="http://jax-ws.dev.java.net/" class="java.lang.NullPointerException" note="To disable this feature, set com.sun.xml.ws.fault.SOAPFaultBuilder.disableCaptureStackTrace system property to false"><ns2:stackTrace><ns2:frame class="ipact.testws1.testws1" file="testws1.java" line="29" method="operation"/><ns2:frame class="sun.reflect.NativeMethodAccessorImpl" file="NativeMethodAccessorImpl.java" line="native" method="invoke0"/><ns2:frame class="sun.reflect.NativeMethodAccessorImpl" file="NativeMethodAccessorImpl.java" line="39" method="invoke"/><ns2:frame class="sun.reflect.DelegatingMethodAccessorImpl" file="DelegatingMethodAccessorImpl.java" line="25" method="invoke"/><ns2:frame class="java.lang.reflect.Method" file="Method.java" line="592" method="invoke"/><ns2:frame class="com.sun.enterprise.webservice.InstanceResolverImpl$1" file="InstanceResolverImpl.java" line="112" method="invoke"/><ns2:frame class="com.sun.xml.ws.server.InvokerTube$2" file="InvokerTube.java" line="146" method="invoke"/><ns2:frame class="com.sun.xml.ws.server.sei.EndpointMethodHandler" file="EndpointMethodHandler.java" line="257" method="invoke"/><ns2:frame class="com.sun.xml.ws.server.sei.SEIInvokerTube" file="SEIInvokerTube.java" line="93" method="processRequest"/><ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="595" method="__doRun"/><ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="554" method="_doRun"/><ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="539" method="doRun"/><ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="436" method="runSync"/><ns2:frame class="com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl" file="AbstractTubeImpl.java" line="106" method="process"/><ns2:frame class="com.sun.enterprise.webservice.MonitoringPipe" file="MonitoringPipe.java" line="147" method="process"/><ns2:frame class="com.sun.xml.ws.api.pipe.helper.PipeAdapter" file="PipeAdapter.java" line="115" method="processRequest"/><ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="595" method="__doRun"/><ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="554" method="_doRun"/><ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="539" method="doRun"/><ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="436" method="runSync"/><ns2:frame class="com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl" file="AbstractTubeImpl.java" line="106" method="process"/><ns2:frame class="com.sun.enterprise.webservice.CommonServerSecurityPipe" file="CommonServerSecurityPipe.java" line="222" method="processRequest"/><ns2:frame class="com.sun.enterprise.webservice.CommonServerSecurityPipe" file="CommonServerSecurityPipe.java" line="133" method="process"/><ns2:frame class="com.sun.xml.ws.api.pipe.helper.PipeAdapter" file="PipeAdapter.java" line="115" method="processRequest"/><ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="595" method="__doRun"/><ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="554" method="_doRun"/><ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="539" method="doRun"/><ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="436" method="runSync"/><ns2:frame class="com.sun.xml.ws.server.WSEndpointImpl$2" file="WSEndpointImpl.java" line="243" method="process"/><ns2:frame class="com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit" file="HttpAdapter.java" line="444" method="handle"/><ns2:frame class="com.sun.xml.ws.transport.http.HttpAdapter" file="HttpAdapter.java" line="244" method="handle"/><ns2:frame class="com.sun.xml.ws.transport.http.servlet.ServletAdapter" file="ServletAdapter.java" line="135" method="handle"/><ns2:frame class="com.sun.enterprise.webservice.JAXWSServlet" file="JAXWSServlet.java" line="177" method="doPost"/><ns2:frame class="javax.servlet.http.HttpServlet" file="HttpServlet.java" line="754" method="service"/><ns2:frame class="javax.servlet.http.HttpServlet" file="HttpServlet.java" line="847" method="service"/><ns2:frame class="org.apache.catalina.core.ApplicationFilterChain" file="ApplicationFilterChain.java" line="427" method="servletService"/><ns2:frame class="org.apache.catalina.core.StandardWrapperValve" file="StandardWrapperValve.java" line="315" method="invoke"/><ns2:frame class="org.apache.catalina.core.StandardContextValve" file="StandardContextValve.java" line="287" method="invokeInternal"/><ns2:frame class="org.apache.catalina.core.StandardContextValve" file="StandardContextValve.java" line="218" method="invoke"/><ns2:frame class="org.apache.catalina.core.StandardPipeline" file="StandardPipeline.java" line="648" method="doInvoke"/><ns2:frame class="org.apache.catalina.core.StandardPipeline" file="StandardPipeline.java" line="593" method="doInvoke"/><ns2:frame class="com.sun.enterprise.web.WebPipeline" file="WebPipeline.java" line="94" method="invoke"/><ns2:frame class="com.sun.enterprise.web.PESessionLockingStandardPipeline" file="PESessionLockingStandardPipeline.java" line="98" method="invoke"/><ns2:frame class="org.apache.catalina.core.StandardHostValve" file="StandardHostValve.java" line="222" method="invoke"/><ns2:frame class="org.apache.catalina.core.StandardPipeline" file="StandardPipeline.java" line="648" method="doInvoke"/><ns2:frame class="org.apache.catalina.core.StandardPipeline" file="StandardPipeline.java" line="593" method="doInvoke"/><ns2:frame class="org.apache.catalina.core.StandardPipeline" file="StandardPipeline.java" line="587" method="invoke"/><ns2:frame class="org.apache.catalina.core.ContainerBase" file="ContainerBase.java" line="1093" method="invoke"/><ns2:frame class="org.apache.catalina.core.StandardEngineValve" file="StandardEngineValve.java" line="166" method="invoke"/><ns2:frame class="org.apache.catalina.core.StandardPipeline" file="StandardPipeline.java" line="648" method="doInvoke"/><ns2:frame class="org.apache.catalina.core.StandardPipeline" file="StandardPipeline.java" line="593" method="doInvoke"/><ns2:frame class="org.apache.catalina.core.StandardPipeline" file="StandardPipeline.java" line="587" method="invoke"/><ns2:frame class="org.apache.catalina.core.ContainerBase" file="ContainerBase.java" line="1093" method="invoke"/><ns2:frame class="org.apache.coyote.tomcat5.CoyoteAdapter" file="CoyoteAdapter.java" line="291" method="service"/><ns2:frame class="com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask" file="DefaultProcessorTask.java" line="666" method="invokeAdapter"/><ns2:frame class="com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask" file="DefaultProcessorTask.java" line="597" method="doProcess"/><ns2:frame class="com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask" file="DefaultProcessorTask.java" line="872" method="process"/><ns2:frame class="com.sun.enterprise.web.connector.grizzly.DefaultReadTask" file="DefaultReadTask.java" line="341" method="executeProcessorTask"/><ns2:frame class="com.sun.enterprise.web.connector.grizzly.DefaultReadTask" file="DefaultReadTask.java" line="263" method="doTask"/><ns2:frame class="com.sun.enterprise.web.connector.grizzly.DefaultReadTask" file="DefaultReadTask.java" line="214" method="doTask"/><ns2:frame class="com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask" file="PortUnificationPipeline.java" line="382" method="doTask"/><ns2:frame class="com.sun.enterprise.web.connector.grizzly.TaskBase" file="TaskBase.java" line="264" method="run"/><ns2:frame class="com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread" file="SSLWorkerThread.java" line="106" method="run"/></ns2:stackTrace></ns2:exception></detail></S:Fault></S:Body></S:Envelope>
--------------------------------
The input envelope sent from the app (also captured with fiddler) looks like this:
--------------------------------
POST http://al2cur:8090/testws1-war/testws1Service HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.1
Host: al2cur:8090
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Content-Length: 471
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body><operation xmlns="http://testws1.ipact/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<inx>
<in1>Richard</in1>
<in2>ab</in2>
</inx>
</operation> </soapenv:Body>
</soapenv:Envelope>
---------------------------------
My envelope from soapUI (which successfuly call the web service) looks like this:
--------------------
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tes="http://testws1.ipact/">
<soapenv:Header/>
<soapenv:Body>
<tes:operation>
<inx>
<in1>Richard</in1>
<in2>ab</in2>
</inx>
</tes:operation>
</soapenv:Body>
</soapenv:Envelope>
--------------------------
When I debug the web service using the app I'm trying to integrate with, the argument to my operation method comes in as a null
When I debug the web service using a java, .net or soapUI client, the argument comes in as expected (as an object of the class I defned to hold my complexType with 2 strings), but the soap envelope is then much simpler. I don't have access to source on the app that is failing in terms of how it structures the envelope sent during the call.
It seems to me that something in the header generated by the app that is failing is causing glassfish (or the jax-ws stuff) to fail parsing the envelope. If I build the exact same kind of webservice with .net, the app can call it successfully. Unfortunately, this isn't an option since the backend I have to call only exposes a java api.
If I comment out any reference to the input object, and just hard code the return object, like so
@WebMethod(operationName = "operation")
public strOutput operation(@WebParam(name = "inx")
strInput inx) {
strOutput x = new strOutput();
//x.setOut1(inx.getIn1());
//x.setOut2(inx.getIn2());
x.setOut1("Test");
x.setOut2("Test1");
return x;
}
The application successfully recieves the 2 strings. This is what leads me to believe it is the unmarshalling/decoding (or whatever the correct term is) of the input envelope that is causing the problem. Unfortunately, I have no idea how to change how Java/Glassfish unmarshals the envelope.....
Is there some annotation or other technique that migth help in reading the envelope correctly? Any advice much appreciated.
Cheers,
Richard
Edited by: user13810815 on 20-Jan-2011 9:42 AM