[ 
https://issues.apache.org/jira/browse/AXIS2-5501?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13642528#comment-13642528
 ] 

Kishanthan Thangarajah commented on AXIS2-5501:
-----------------------------------------------

Your observation is correct. There is indeed a change from axis2 1.5.6. In 
axis2 1.5.6, the transportOut is retrieved in the CommonsHTTPTransportSender's 
invoke method it self [1] using messageContext. This was actually wrong and 
from 1.6.0 on-wards, it is properly fixed to use the transportOut object in the 
init method of the CommonsHTTPTransportSender. According the commit logs, this 
change was added to properly fix [2]. So my observation is, when using 
CommonsHTTPTransportSender, we have to first initialize it, before using it.

Currently according to the logic in ConfigurationContextFactory class, if we 
use createDefaultConfigurationContext(), the transports senders will not get 
initialized and a NPE will get thrown from CommonsHTTPTransportSender#invoke 
method, where it tries to use the transportOut object.

But if we use createConfigurationContextFromFileSystem(null, null), it will 
work without any issue, because, it calls the initTranspsortSenders method to 
properly initialize all transport senders. 

Thanks,
Kishanthan.
[1] 
http://svn.apache.org/repos/asf/axis/axis2/java/core/tags/v1.5.6/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
[2] https://issues.apache.org/jira/browse/AXIS2-4648
                
> Creating ServiceClient with ConfigContext created using 
> createDefaultConfigurationContext() causes NullPointerException
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: AXIS2-5501
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5501
>             Project: Axis2
>          Issue Type: Bug
>          Components: transports
>    Affects Versions: 1.6.0, 1.6.1, 1.6.2
>         Environment: Any.  Testing on Windows 7 with java 1.5.
>            Reporter: Barry Tarlton
>            Priority: Critical
>              Labels: nullpointer, transport
>             Fix For: 1.5.6
>
>
> Something has changed from 1.5.6 to 1.6.0 in the axis2-transport-http.jar 
> that causes a null pointer exception if you initialize your ServiceClient 
> with an ConfigurationContext that was created by calling 
> ConfigurationContextFactory.createDefaultConfigurationContext().  
> Here's the modified sample that shows the behavior:
> public class EchoBlockingClient {
>     private static EndpointReference targetEPR = new 
> EndpointReference("http://localhost:8080/checkSoap";);
>     public static void main(String[] args) throws Exception {
>         try {
>             OMElement payload = ClientUtil.getEchoOMElement();
>             Options options = new Options();
>             options.setTo(targetEPR);
>             options.setAction("urn:echo");
>             // create config using defaultConfigurationContext... 
>             // this does not initialize the transportOutDescription's 
> sender's transportOut and causes a null pointer
>             ConfigurationContext defaultContext= 
> ConfigurationContextFactory.createDefaultConfigurationContext();
>             
>             
>             // this initializes the transportOut.sender.transportOut properly 
> and allows it to work.
>             // ConfigurationContext defaultContext= 
> ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, 
> null);
>             
>             
>             
>             //Blocking invocation
>             ServiceClient sender = new ServiceClient(defaultContext, null);
>             sender.setOptions(options);
>             OMElement result = sender.sendReceive(payload);
>             System.out.println(result);
>         } catch (AxisFault axisFault) {
>             axisFault.printStackTrace();
>         }
>     }
> I see the following exception when doing so:
> Exception in thread "main" java.lang.NullPointerException
>       at 
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:172)
>       at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443)
> This is because the TransportOutDescription is never set on the 
> CommonHTTPTransportSender.  
> If I change the code and use the
> ConfigurationContext defaultContext= 
> ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, 
> null);
> Then this code works fine.
> I can also, just replace the axis2-transport-http-1.6.0.jar with the 
> axis2-transport-http-1.5.6.jar and it will work either way.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscr...@axis.apache.org
For additional commands, e-mail: java-dev-h...@axis.apache.org

Reply via email to