Reputation: 2160
I am trying to query contacts from salesForce account but getting above error.
I generated enterprise.jar
file from the WSDL downloaded from my account.
I have wsc-23-min.jar
along with enterprise.jar
files in libs
folder.
Below method is used to query contacts
private void queryContacts() {
Log.i(TAG, "Querying for the 5 newest Contacts...");
ConnectorConfig config = new ConnectorConfig();
config.setUsername("***@***.com");
config.setPassword("***");
try {
connection = Connector.newConnection(config);
// query for the 5 newest contacts
com.sforce.soap.enterprise.QueryResult queryResults = connection.query("SELECT Id, FirstName, LastName, Account.Name " +
"FROM Contact WHERE AccountId != NULL ORDER BY CreatedDate DESC LIMIT 5");
if (queryResults.getSize() > 0) {
for (int i=0;i<queryResults.getRecords().length;i++) {
// cast the SObject to a strongly-typed Contact
Contact c = (Contact)queryResults.getRecords()[i];
Log.i(TAG, " ------------- Id: " + c.getId() + " - Name: "+c.getFirstName()+" "+
c.getLastName()+" - Account: "+c.getAccount().getName());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
Any help or clue is appreciated. Thanks.
Edit:
I tried all the methods from this popular question but no luck.
I have other projects in my workspace which are having jar files (in 'libs' folder) and they all work properly. Don’t know whats wrong with salesforce related jar files.
Edit:
There is no problem with wsc-23.jar
file. Classes placed in this jar, for ex. Connector
and others loading and they are working fine.
Only problem is with generated enterprise.jar
through WSDL file.
Followed this to generate enterprise.jar file
Not getting what's wrong with it.
Upvotes: 2
Views: 2468
Reputation: 2160
Finally got the solution for my problem.
Here is a link for the answer.
Upvotes: 0
Reputation: 14808
You should place your jar in libs
folder not in lib
folder. After that goto Project properties and add the jar to java build path
.
Upvotes: 2