0

I am getting a java.lang.NullPointerException while trying to call a Soap web service with javax.xml.soap.SOAPConnection object.

I am sure the endpointAddress and request parameters are as they should be(i have printed them out). And the stack trace is as follows:

    Caused by: java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:394)
at java.util.Properties.put(Properties.java:152)
at org.w3c.www.protocol.http.HttpManager.a(SourceFile:561)
at org.w3c.www.protocol.http.HttpManager.getManager(SourceFile:583)
at org.w3c.www.protocol.http.HttpManager.getManager(SourceFile:747)
at org.w3c.www.protocol.http.HttpURLConnection.checkRequest(SourceFile:108)
at org.w3c.www.protocol.http.HttpURLConnection.a(SourceFile:799)
at org.w3c.www.protocol.http.HttpURLConnection.setRequestProperty(SourceFile:778)
at com.sap.security.core.server.https.SecureConnectionFactory.createURLConnection(SecureConnectionFactory.java:999)
at com.sap.security.core.server.https.SecureConnectionFactory.createURLConnection(SecureConnectionFactory.java:891)
at com.sap.engine.httpdsrclient.protocols.https.Handler.openConnection(Handler.java:53)
at java.net.URL.openConnection(URL.java:965)
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.createConnection(HttpSOAPConnection.java:669)
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:186)

The awkward part of this error is: it works for a while if i restart the application server. It works for a while (about a few hours) and then it starts to getting this error.

Please help me to solve the problem.

The source is as below:

private SOAPMessage callService2(SOAPMessage request, String endpointAddress) throws Exception {
    SOAPConnection connection = null;
    try {
        System.setProperty("sun.net.client.defaultConnectTimeout","300000");
        System.setProperty("sun.rmi.transport.proxy.connectTimeout","300000");
        connection = SOAPConnectionFactory.newInstance().createConnection();
        URL endpointAddressURL = new URL(endpointAddress);
        return connection.call(request, endpointAddressURL);
    }
    catch (Exception e) {
        throw e;
    }
    finally {
        if(connection != null) {
            connection.close();
        }
    }
}
xuxux
  • 1
  • 1
  • 2
  • Possible duplicate of [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) –  Nov 01 '17 at 15:54
  • Actually the nullpointerexception occurs at Hashtable object and it is used in java.net.URL object. How can fix this? Should i set some arguments in java.util.Properties manually before this exception occurs? – xuxux Nov 02 '17 at 06:36

0 Answers0