2

I have a Spring Bean config to login to Salesforce using the Enterprise API. It looks like follows:

@Bean(name="loginToSalesforceProductionEnterprise")
    public EnterpriseConnection loginToProductionSalesforceEnterprise() {
        try {
            final ConnectorConfig config = new ConnectorConfig();
            config.setUsername("username");
            config.setPassword("password");
            config.setAuthEndpoint("https://login.salesforce.com/services/Soap/c/29.0");
            enterpriseConnection = new EnterpriseConnection(config);
        } catch (ConnectionException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return enterpriseConnection;
    }

Then I have a Junit Test to my login:

package com.sforce.authentication;

import static org.junit.Assert.*;

import javax.inject.Inject;
import javax.inject.Named;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;

import com.sforce.soap.enterprise.sobject.wsc.Account;
import com.sforce.soap.enterprise.wsc.EnterpriseConnection;
import com.sforce.soap.enterprise.wsc.SaveResult;
import com.sforce.ws.ConnectionException;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(loader=AnnotationConfigContextLoader.class, classes={SalesforceAuthenticationConfigImpl.class})
public class EnterpriseConnectionTest {

    @Inject @Named("loginToSalesforceProductionEnterprise") EnterpriseConnection loginToSalesforceEnterpriseConnection;

    @Test
    public void test() throws ConnectionException {
        Account newAccount = new Account();
        newAccount.setName("Test");
        SaveResult[] sr = loginToSalesforceEnterpriseConnection.create(new Account[]{newAccount});
        System.out.println(sr[0].getSuccess());
        assertNotNull(sr);
    }
}

The test just never completes and seems to be stuck, but when I go look in Salesforce I can see the Account has been created. Looks like SaveResult[] never returns anything but it also doesn't fail. Any suggestions?

7
  • Strange I have a feeling i got this the other day, i found it would just hang, when i stopped it in the debugger the stack trace showed it looping parsing the response from the salesforce server. I'm trying to remember what I did, i suspect it might have been down to wsc version i was using. Are you using the latest v29 version of wsc? Commented Nov 4, 2013 at 18:51
  • Yes using the v29. I have also set config.setTraceMessage(true); config.setPrettyPrintXml(true); and can see the request and response soap message was successful. Commented Nov 4, 2013 at 18:58
  • Are you able to debug it and hault processing to review the current stack trace? Commented Nov 4, 2013 at 19:04
  • Yes but don't see anything unusual. It does the insert, and returns the SaveResult but never gets to System.out.println(sr[0].getSuccess()); Commented Nov 4, 2013 at 20:09
  • 1
    I think it was a test peace of code i was writing, i moved out from a more complex project, multiple dependencies in the pom.xml (it was a maven project) and create a basic one, so basically i side stepped it. Reflecting on it, i suspect it was a bad interplay between dependent libraries. Try creating a smaller app (if your using maven) and see what versions of dependencies it brings in vs whats in your larger app? Commented Nov 5, 2013 at 18:30

1 Answer 1

1

I had this issue once, while I'm not 100% sure what it was, i recall i had a mix of old and new dependent jar libraries. I switched to a standalone app that brought in the required versions of the jars via the Maven build process. Worth doing that and then comparing how far adrift your main apps jar versions are, and updating some of those.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .