I had to connect to salesforce through my Java application and followed the steps provided by salesforce.com Introduction. I faced a couple of issues in this process and any help would really help me a lot.
Issue 1: First and foremeost I am unable to build
wsc.jarafter cloning the project from GIT. The project gives a compilation error when imported inmyeclipsewhen compiler version is 1.6. There were no errors if I change the compiler version to 1.7.Issue 2: Instead of building jar file , I downloaded
wsc-20.jarfrom an online resource (link provided in comments below) and generatedenterprise.jarfrom the WSDL given to me by a salesforce developer. I includedwsc-23.jarandenterprise.jarin my project buildpath and implemented the code as provided by salesforce(link provided below). When I run the code, a runtime exception is encountered as below and the request failed to sent totest.salesforce.com. The exception and error log are provided below.
After certain investigation, I found out that the API libraries and the Java code are working perfectly fine when Java JRE version is switched to 1.7. But somehow this isn't working in 1.6 environment and I get the below error and I cannot upgrade my project's Java version to 1.7.
Runtime Exception:
com.sforce.ws.ConnectionException: Failed to send request to https://test.salesforce.com/services/Soap/c/36.0/ at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:129) at com.sforce.soap.enterprise.EnterpriseConnection.login(EnterpriseConnection.java:1) at com.sforce.soap.enterprise.EnterpriseConnection.(EnterpriseConnection.java:1) at com.nsf.ecap.web.business.proposal.SalesforceLoginTest.main(SalesforceLoginTest.java:27) Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1611) at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:187) at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:181) at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1035) at [1]com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:124) at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:516) at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:454)
Any suggestions would be greatly helpful.