function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Problem in binding to web service



I have written a simple program to download the record..

Here is the progrma i have written



package com.demo;
import com.sforce.soap.enterprise.LoginResult;
import com.sforce.soap.enterprise.QueryResult;
import com.sforce.soap.enterprise.SessionHeader;
import com.sforce.soap.enterprise.SforceServiceLocator;
import com.sforce.soap.enterprise.SoapBindingStub;
import com.sforce.soap.enterprise.sobject.*;

public class RunDemo {

    public static final String USERNAME = "";
    public static final String TOKEN = "";
    public static final String PASSWORD ="";
     * @param args
    private SoapBindingStub binding;
    public static void main(String[] args) {
        RunDemo r = new RunDemo();
        try {
        } catch (Exception e) {


    private void login() throws Exception{
//        System.setProperty("http.proxySet", "true");
//        System.setProperty("http.proxyHost", "localhost");
//        System.setProperty("http.proxyPort", "8080");
//        System.setProperty("http.proxyUser", "rajiv");
//        System.setProperty("http.proxyPassword", "rajiv");
//        System.out.println("Logging into Salesforce.....");
        binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
        System.out.println("Before Login");
        LoginResult loginResult = binding.login(USERNAME, PASSWORD);
        binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, loginResult.getServerUrl());
        SessionHeader sh = new SessionHeader();
        binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(),"SessionHeader",sh);

    private void search() throws Exception{
        QueryResult qr = binding.query("Select FirstName,LastName from Contact");
        if (qr.getSize() > 0){
            for (int i = 0; i < qr.getSize(); i++) {
            Contact c = (Contact) qr.getRecords(i);
            System.out.println("First Name :" + c.getFirstName() + "Last Name" + c.getLastName());




I am getting exception on line 


 binding = (SoapBindingStub) new SforceServiceLocator().getSoap();




Here is the exception which i am getting while trying to run the program....



Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.apache.axis.client.Service.getAxisClient(
    at org.apache.axis.client.Service.<init>(
    at com.sforce.soap.enterprise.SforceServiceLocator.<init>(
    at com.demo.RunDemo.login(
    at com.demo.RunDemo.main(
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException))
    at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(
    at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(
    at org.apache.commons.logging.LogFactory.getLog(
    at org.apache.axis.components.logger.LogFactory.getLog(
    at org.apache.axis.handlers.BasicHandler.<clinit>(
    ... 5 more
Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException)
    at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(
    at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(
    ... 9 more
Caused by: java.lang.NullPointerException
    at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(
    ... 10 more




Any help on this will be great help 








Your exception is pretty obvious, SoapBindingStub is not visible or in simplier terms the host cannot be found. Can you confirm the URL your ServiceStub is pointing to?


The reason why i am asking this, is because you end up with below exception giving the indication, your ServiceStub configuration cannot see salesforce service host within.



java.lang.NullPointerException (Caused by java.lang.NullPointerException