You need to sign in to do that
Don't have an account?
Force.com
How to call salesforce from Java code running on EC2 ?
Hello,
I have a java servlet running on EC2 server of Amazon. This servlet calls salesforce by setting up connection with EnterpriseConnection class.
I ran this java servlet in java enviornment and the code was working. However when I ran the same java servlet by hosting it on EC2 server, it is throwing the following exception:
java.lang.NoClassDefFoundError: com/sforce/ws/ConnectionException java.lang.Class.getDeclaredConstructors0(Native Method) java.lang.Class.privateGetDeclaredConstructors(Class.java:2389) java.lang.Class.getConstructor0(Class.java:2699) java.lang.Class.newInstance0(Class.java:326) java.lang.Class.newInstance(Class.java:308) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405) org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:197) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515) org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1824) java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
I have imported wsc-20.jar and enterprise.jar files in the code. Still facing this issue.
Is there any other way to call salesforce from java running on EC2?
Please help. Any help will be highly appreciated.
Thanks
Hi cloudcoder, SimonF,
Thanks a lot.
Issue is resolved now.
Cause of this exception was: I forgot to restart Tomcat after adding jar files in its lib folder.
All Answers
Certainly sounds like a classpath issue. Of course, you could use the Force.com REST API, then you don't need SOAP or WSDLs. :)
http://developer.force.com/REST
I have set the classpath of wsc-20 jar. Still facing this issue. At this point of time, I can not convert the complete code to support REST APIs but I will surely give it a try later.
Is calling Salesforce through Soap or wsdls not supported on EC2?
I failed to understand why I am facing this ConnectionException issue when running the code on EC2 while it is working when I am running it in java enviornment.\
Thanks
It sounds like your runtime environment doesn't have the right classpath. (or perhaps you haven't deployed all the jars?)
Hi SimonF,
Thanks for your reply.
All the jar files are present in the lib folder of Tomcat.
In Command prompt, I am writing following classpath:
set classpath=.;C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\commons-cli-1.2.jar;C:
Hi cloudcoder, SimonF,
Thanks a lot.
Issue is resolved now.
Cause of this exception was: I forgot to restart Tomcat after adding jar files in its lib folder.