[ https://issues.apache.org/jira/browse/AXIS2-5501?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13881212#comment-13881212 ]
Magdalena Krygielova commented on AXIS2-5501: --------------------------------------------- Hi Kishanthan, I have run into a similar issue (I am using the createBasicConfigurationContext(MY_RESOURCE)). But I still don't understand the solution. What are those methods for if they cannot be used? What shall I use instead? Thanks Magda > 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 > Assignee: Kishanthan Thangarajah > 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 was sent by Atlassian JIRA (v6.1.5#6160) --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscr...@axis.apache.org For additional commands, e-mail: java-dev-h...@axis.apache.org