• Salesforce_Developer.ax1278
  • 0 Points
  • Member since 2012

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 5


           I am able to connect to Saleforce sandbox by the Bulk API call as a stand alone application(no errors). But when i do the same thing through the weblogic server web application, i get the following error,


   <Warning> <Security> <BEA-090477> <Certificate chain received from test.salesforce.com - was not trusted causing SSL handshake failure.>


          I am not using any proxy server.


      Can anyone please help me.


           I am able to connect to Saleforce sandbox by the Bulk API call as a stand alone application(no errors). But when i do the same thing through the weblogic server web application, i get the following error,


   <Warning> <Security> <BEA-090477> <Certificate chain received from test.salesforce.com - was not trusted causing SSL handshake failure.>


          I am not using any proxy server.


      Can anyone please help me.



I am trying use the SOAP login call for portal user. With the user credentials, I could login through portal login page in browser. I am trying to login the same user using SOAP call (portal id and organization id are provided in request). But the call is failing with error message "INVALID_LOGIN: Invalid username, password, security token; or user locked out.".


Can you please help me in handling this. Do We need to have some settings for the user so that soap login is allowed?



I used to switch login for Data Loader in DEV as well as QA for any testing. And I never forget to provide Proxy settings value while switch to DEV environment and QA doesn't required it.


Today I got the below error while login into DEV environment and I had received this error before but it was fixed after some changes in Proxy settings.


"Failed to send request to https://test.salesforce.com//services/Soap/u/19.0"


Can anyone please help me to resolve this issue?




  • August 03, 2011
  • Like
  • 0



  I am trying Bulk API Enterprise WSD in SandBox the below error is coming


 Exception in thread "main" [AsyncApiException  exceptionCode='ClientInputError'
 exceptionMessage='Failed to create job '

 at com.sforce.async.RestConnection.createOrUpdateJob(RestConnection.java:102)
 at com.sforce.async.RestConnection.createJob(RestConnection.java:76)
 at client.BulkClient.createJob(BulkClient.java:162)
 at client.BulkClient.runSample(BulkClient.java:56)
 at client.BulkClient.main(BulkClient.java:45)
Caused by: java.net.NoRouteToHostException: No route to host: connect
 at java.net.PlainSocketImpl.socketConnect(Native Method)
 at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
 at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
 at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
 at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
 at java.net.Socket.connect(Socket.java:519)
 at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:550)
 at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:141)
 at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
 at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
 at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
 at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:271)
 at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:328)
 at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:172)
 at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:816)
 at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:158)
 at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:881)
 at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)
 at com.sforce.ws.transport.JdkHttpTransport.connectLocal(JdkHttpTransport.java:132)
 at com.sforce.ws.transport.JdkHttpTransport.connect(JdkHttpTransport.java:63)
 at com.sforce.async.RestConnection.createOrUpdateJob(RestConnection.java:82)
 ... 4 more




package client;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.xml.rpc.ServiceException;

import com.sforce.async.AsyncApiException;
import com.sforce.async.BatchInfo;
import com.sforce.async.BatchStateEnum;
import com.sforce.async.CSVReader;
import com.sforce.async.ContentType;
import com.sforce.async.JobInfo;
import com.sforce.async.JobStateEnum;
import com.sforce.async.OperationEnum;
import com.sforce.async.RestConnection;
import com.sforce.soap.enterprise.LoginResult;
import com.sforce.soap.enterprise.SessionHeader;
import com.sforce.soap.enterprise.SforceServiceLocator;
import com.sforce.soap.enterprise.SoapBindingStub;
import com.sforce.soap.enterprise.fault.ExceptionCode;
import com.sforce.soap.enterprise.fault.LoginFault;
import com.sforce.ws.ConnectionException;
import com.sforce.ws.ConnectorConfig;

public class BulkClient {
 private LoginResult loginResult;

  * @param args
 public static void main(String[] args) throws ServiceException,AsyncApiException,
   ConnectionException, IOException {
  BulkClient bc = new BulkClient();
  bc.runSample("Account", "userID", "password", "Sample.csv");

  * Creates a Bulk API. job and uploads batches for a CSV file.
 public void runSample(String sobjectType, String userName, String password,
   String sampleFileName) throws ServiceException,AsyncApiException,
   ConnectionException, IOException {
  login(userName, password);
  RestConnection connection = getRestConnection();
  JobInfo job = createJob(sobjectType, connection);
  List<BatchInfo> batchInfoList = createBatchesFromCSVFile(connection,
    job, sampleFileName);
  closeJob(connection, job.getId());
  awaitCompletion(connection, job, batchInfoList);
  checkResults(connection, job, batchInfoList);

 private boolean login(String userName, String password) throws ServiceException {
  SoapBindingStub binding = (SoapBindingStub) new SforceServiceLocator().getSoap();

  // Time out after a minute
  System.getProperties().put("proxySet", "true");
  System.getProperties().put("http.proxyHost", "proxy");
  System.getProperties().put("http.proxyPort", "8080");

  try {
   System.out.println("LOGGING IN NOW....");
   loginResult = binding.login(userName, password);
  } catch (LoginFault ex) {
   // The LoginFault derives from AxisFault
   ExceptionCode exCode = ex.getExceptionCode();
   if (exCode == ExceptionCode.FUNCTIONALITY_NOT_ENABLED
     || exCode == ExceptionCode.INVALID_CLIENT
     || exCode == ExceptionCode.INVALID_LOGIN
     || exCode == ExceptionCode.LOGIN_DURING_RESTRICTED_DOMAIN
     || exCode == ExceptionCode.LOGIN_DURING_RESTRICTED_TIME
     || exCode == ExceptionCode.ORG_LOCKED
     || exCode == ExceptionCode.PASSWORD_LOCKOUT
     || exCode == ExceptionCode.SERVER_UNAVAILABLE
     || exCode == ExceptionCode.TRIAL_EXPIRED
     || exCode == ExceptionCode.UNSUPPORTED_CLIENT) {
      .println("Please be sure that you have a valid username "
        + "and password.");
   } else {
    // Write the fault code to the console
    // Write the fault message to the console
    System.out.println("An unexpected error has occurred."
      + ex.getMessage());
   return false;
  } catch (Exception ex) {
   System.out.println("An unexpected error has occurred: "
     + ex.getMessage());
   return false;
  // Check if the password has expired
  if (loginResult.isPasswordExpired()) {
     .println("An error has occurred. Your password has expired.");
   return false;
  SessionHeader sh = new SessionHeader();
  binding.setHeader(new SforceServiceLocator().getServiceName()
    .getNamespaceURI(), "SessionHeader", sh);
  return true;

  * Create the RestConnection used to call Bulk API operations.
 private RestConnection getRestConnection()
   throws ConnectionException, AsyncApiException {

  ConnectorConfig config = new ConnectorConfig();
  String soapEndpoint = loginResult.getServerUrl();
  String apiVersion = "17.0";
  String restEndpoint = soapEndpoint.substring(0, soapEndpoint
    + "async/" + apiVersion;
  RestConnection connection = new RestConnection(config);
  return connection;

  * Create a new job using the Bulk API.
  * @param sobjectType
  *            The object type being loaded, such as "Account"
  * @param connection
  *            RestConnection used to create the new job.
  * @return The JobInfo for the new job.
  * @throws AsyncApiException
 private JobInfo createJob(String sobjectType, RestConnection connection)
   throws AsyncApiException {
  JobInfo job = new JobInfo();
//  System.getProperties().put("proxySet", "true");
//  System.getProperties().put("http.proxyHost", "proxy");
//  System.getProperties().put("http.proxyPort", "8080");
  job = connection.createJob(job);
  return job;

 private List<BatchInfo> createBatchesFromCSVFile(RestConnection connection,
   JobInfo jobInfo, String csvFileName) throws IOException,
   AsyncApiException {
  List<BatchInfo> batchInfos = new ArrayList<BatchInfo>();
  BufferedReader rdr = new BufferedReader(new InputStreamReader(
    new FileInputStream(csvFileName)));
  // read the CSV header row
  byte[] headerBytes = (rdr.readLine() + "\n").getBytes("UTF-8");
  int headerBytesLength = headerBytes.length;
  File tmpFile = File.createTempFile("bulkAPIInsert", ".csv");
  // Split the CSV file into multiple batches
  try {
   FileOutputStream tmpOut = new FileOutputStream(tmpFile);
   int maxBytesPerBatch = 10000000; // 10 million bytes per batch
   int maxRowsPerBatch = 10000; // 10 thousand rows per batch
   int currentBytes = 0;
   int currentLines = 0;
   String nextLine;
   while ((nextLine = rdr.readLine()) != null) {
    byte[] bytes = (nextLine + "\n").getBytes("UTF-8");
    // Create a new batch when our batch size limit is reached
    if (currentBytes + bytes.length > maxBytesPerBatch
      || currentLines > maxRowsPerBatch) {
     createBatch(tmpOut, tmpFile, batchInfos, connection,
     currentBytes = 0;
     currentLines = 0;
    if (currentBytes == 0) {
     tmpOut = new FileOutputStream(tmpFile);
     currentBytes = headerBytesLength;
     currentLines = 1;
    currentBytes += bytes.length;
   // Finished processing all rows
   // Create a final batch for any remaining data
   if (currentLines > 1) {
    createBatch(tmpOut, tmpFile, batchInfos, connection, jobInfo);
  } finally {
  return batchInfos;

 private void createBatch(FileOutputStream tmpOut, File tmpFile,
   List<BatchInfo> batchInfos, RestConnection connection,
   JobInfo jobInfo) throws IOException, AsyncApiException {
  FileInputStream tmpInputStream = new FileInputStream(tmpFile);
  try {
   BatchInfo batchInfo = connection.createBatchFromStream(jobInfo,
  } finally {

 private void closeJob(RestConnection connection, String jobId)
   throws AsyncApiException {
  JobInfo job = new JobInfo();

 private void awaitCompletion(RestConnection connection, JobInfo job,
   List<BatchInfo> batchInfoList) throws AsyncApiException {
  long sleepTime = 0L;
  Set<String> incomplete = new HashSet<String>();
  for (BatchInfo bi : batchInfoList) {
  while (!incomplete.isEmpty()) {
   try {
   } catch (InterruptedException e) {
   System.out.println("Awaiting results..." + incomplete.size());
   sleepTime = 10000L;
   BatchInfo[] statusList = connection.getBatchInfoList(job.getId())
   for (BatchInfo b : statusList) {
    if (b.getState() == BatchStateEnum.Completed
      || b.getState() == BatchStateEnum.Failed) {
     if (incomplete.remove(b.getId())) {
      System.out.println("BATCH STATUS:\n" + b);

 private void checkResults(RestConnection connection, JobInfo job,
   List<BatchInfo> batchInfoList) throws AsyncApiException,
   IOException {
  // batchInfoList was populated when batches were created and submitted
  for (BatchInfo b : batchInfoList) {
   CSVReader rdr = new CSVReader(connection.getBatchResultStream(job
     .getId(), b.getId()));
   List<String> resultHeader = rdr.nextRecord();
   int resultCols = resultHeader.size();
   List<String> row;
   while ((row = rdr.nextRecord()) != null) {
    Map<String, String> resultInfo = new HashMap<String, String>();
    for (int i = 0; i < resultCols; i++) {
     resultInfo.put(resultHeader.get(i), row.get(i));
    boolean success = Boolean.valueOf(resultInfo.get("Success"));
    boolean created = Boolean.valueOf(resultInfo.get("Created"));
    String id = resultInfo.get("Id");
    String error = resultInfo.get("Error");
    if (success && created) {
     System.out.println("Created row with id " + id);
    } else if (!success) {
     System.out.println("Failed with error: " + error);


In the above Source code Login is OK, after that creating Job with Restful connection error occured

Bulk API need to set Proxy ?? ,Because i am running this application in Proxy network.




Please Help


Thanks and Regards


Message Edited by thangasan@yahoo on 10-18-2009 11:24 PM