• Hanumanthreddy
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

Hi

 

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 {
            r.login();
            r.search();
        } 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();
        sh.setSessionId(loginResult.getSessionId());
        
        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(Service.java:104)
    at org.apache.axis.client.Service.<init>(Service.java:113)
    at com.sforce.soap.enterprise.SforceServiceLocator.<init>(SforceServiceLocator.java:16)
    at com.demo.RunDemo.login(RunDemo.java:40)
    at com.demo.RunDemo.main(RunDemo.java:22)
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(LogFactoryImpl.java:543)
    at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:370)
    at org.apache.axis.components.logger.LogFactory.getLog(LogFactory.java:37)
    at org.apache.axis.handlers.BasicHandler.<clinit>(BasicHandler.java:43)
    ... 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(LogFactoryImpl.java:397)
    at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
    ... 9 more
Caused by: java.lang.NullPointerException
    at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:374)
    ... 10 more

 

 

 

Any help on this will be great help 

 

Thanks