You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Eran Chinthaka (JIRA)" <ji...@apache.org> on 2006/06/06 11:26:30 UTC

[jira] Resolved: (AXIS2-787) POST request from a REST client will cause a NullPointerException in the service

     [ http://issues.apache.org/jira/browse/AXIS2-787?page=all ]
     
Eran Chinthaka resolved AXIS2-787:
----------------------------------

    Resolution: Fixed
     Assign To: Eran Chinthaka  (was: Deepal Jayasinghe)

Added the given code and now there won't be any NPE. Thanks Kent. 

> POST request from a REST client will cause a NullPointerException in the service
> --------------------------------------------------------------------------------
>
>          Key: AXIS2-787
>          URL: http://issues.apache.org/jira/browse/AXIS2-787
>      Project: Apache Axis 2.0 (Axis2)
>         Type: Bug

>   Components: core
>     Versions: 1.0
>     Reporter: Kent Tong
>     Assignee: Eran Chinthaka

>
> In RESTUtil.java in the processPostRequest() method:
>             msgContext.setEnvelope(soapEnvelope);
>             msgContext.setProperty(HTTPConstants.HTTP_METHOD, HTTPConstants.HTTP_METHOD_POST);
>             msgContext.setProperty(HTTPConstants.CONTENT_TYPE, contentType);
>             msgContext.setDoingREST(true);
> It seems that an extra line should be add:
>             msgContext.setEnvelope(soapEnvelope);
>             msgContext.setProperty(HTTPConstants.HTTP_METHOD, HTTPConstants.HTTP_METHOD_POST);
>             msgContext.setProperty(HTTPConstants.CONTENT_TYPE, contentType);
>             msgContext.setDoingREST(true);
>             //ADD THIS LINE
>             msgContext.setProperty(MessageContext.TRANSPORT_OUT, response.getOutputStream());
> Otherwise the TRANSPORT_OUT is not set and the service won't be able to output the response, producing a stack trace like:
> java.lang.NullPointerException
>         at java.io.Writer.<init>(Writer.java:70)
>         at java.io.OutputStreamWriter.<init>(OutputStreamWriter.java:79)
>         at org.apache.axiom.om.impl.MTOMXMLStreamWriter.<init>(MTOMXMLStreamWriter.java:74)
>         at org.apache.axiom.om.impl.llom.OMNodeImpl.serializeAndConsume(OMNodeImpl.java:380)
>         at org.apache.axis2.transport.http.CommonsHTTPTransportSender.sendUsingOutputStream(CommonsHTTPTransportSender.java:256)
>         at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:210)
>         at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:589)
>         at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:43)
>         at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:454)
>         at org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(RESTUtil.java:150)
>         at org.apache.axis2.transport.http.util.RESTUtil.processPostRequest(RESTUtil.java:100)
>         at org.apache.axis2.transport.http.AxisRESTServlet.doPost(AxisRESTServlet.java:43)
> For the moment actually the response argument is not used at all in the processPostRequest() method. In contrast, the processPostRequest() method does perform this step.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org