相关文章推荐
千杯不醉的烈马  ·  Bedtools 使用-CSDN博客·  4 月前    · 
私奔的柳树  ·  springboot ...·  1 年前    · 

Welcome to Support!

Search for an answer or ask a question of the zone or Customer Support.

Need help? Dismiss Show All Questions sorted by Date Posted

Show

sorted by

jcooke1.3959364651695654E12 jcooke1.3959364651695654E12

Random error "java.net.UnknownHostException: cs9.salesforce.com" with Java webservice

We are building a java webservice to update records on a sandbox.

We are getting random errors with the connection timing out.  2 out of every 3 connections fail to connect to the sandbox.  When we traced the error we noticed that we are getting the error: java.net.UnknownHostException: cs9.salesforce.com

We are not using a proxy server

This is the error log:

First Attempt Exception:

2014-03-27 07:21:54,072 ERROR [JMS Async S55]                       CSSCustInfoToGF     - Bulk API Connection Exception Occured
com.sforce.ws.ConnectionException: Failed to send request to https://test.salesforce.com/services/Soap/u/30.0/0DFK0000000Cb1t
at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:129)
at com.sforce.soap.partner.PartnerConnection.login(PartnerConnection.java:1201)

at com.sforce.soap.partner.PartnerConnection.<init>(PartnerConnection.java:421)
at com.ngrid.css.CSSCustInfoToGF.getBulkConnection(CSSCustInfoToGF.java:1258)
at com.ngrid.css.CSSCustInfoToGF.uploadBatchToBulkAPI(CSSCustInfoToGF.java:1105)
at com.ngrid.css.CSSCustInfoToGF.mapCSSAccountRequest(CSSCustInfoToGF.java:361)
at com.ngrid.css.CSSCustInfoToGF.onMessage(CSSCustInfoToGF.java:151)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1011)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:175)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2928)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4019)
at com.sun.ejb.containers.MessageBeanContainer.deliverMessage(MessageBeanContainer.java:1111)
at com.sun.ejb.containers.MessageBeanListenerImpl.deliverMessage(MessageBeanListenerImpl.java:74)
at com.sun.enterprise.connectors.inflow.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:179)
at com.sun.proxy.$Proxy71.onMessage(Unknown Source)
at com.stc.jmsjca.core.XMessageEndpoint.onMessage(XMessageEndpoint.java:60)
at com.stc.jmsjca.core.Delivery.deliverToEndpoint(Delivery.java:1068)
at com.stc.jmsjca.core.SerialDelivery.onMessage(SerialDelivery.java:253)
at com.stc.jms.client.SessionImpl.processAsyncDataAvailable(SessionImpl.java:1661)
at com.stc.jms.client.SessionImpl.processAsync(SessionImpl.java:1750)
at com.stc.jms.client.SessionImpl.asyncEnter(SessionImpl.java:1778)
at com.stc.jms.client.SessionImpl.access$500(SessionImpl.java:56)
at com.stc.jms.client.SessionImpl$1.run(SessionImpl.java:1556)
at com.stc.jms.client.SessionImpl$2.run(SessionImpl.java:1809)
at java.lang.Thread.run(Thread.java:761)
Caused by:
java.net.UnknownHostException: test.salesforce.com
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:253)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:376)
at java.net.Socket.connect(Socket.java:546)
at com.ibm.jsse2.SSLSocketImpl.connect(SSLSocketImpl.java:11)
at sun.net.NetworkClient.doConnect(NetworkClient.java:170)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:437)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:551)
at com.ibm.net.ssl.www2.protocol.https.c.<init>(c.java:116)
at com.ibm.net.ssl.www2.protocol.https.c.a(c.java:105)
at com.ibm.net.ssl.www2.protocol.https.d.getNewHttpClient(d.java:12)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:978)
at com.ibm.net.ssl.www2.protocol.https.d.connect(d.java:43)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1043)
at com.ibm.net.ssl.www2.protocol.https.b.getOutputStream(b.java:71)
at com.sforce.ws.transport.JdkHttpTransport.connectRaw(JdkHttpTransport.java:115)
at com.sforce.ws.transport.JdkHttpTransport.connect(JdkHttpTransport.java:79)
at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:107)
... 28 more

Second Attempt Exception:

2014-03-27 07:52:20,206 ERROR [JMS Async S52]                       CSSCustInfoToGF     - Exception occured while creating the Job |

[AsyncApiException  exceptionCode='ClientInputError'
exceptionMessage='Failed to create job '
]
at com.sforce.async.BulkConnection.createOrUpdateJob(BulkConnection.java:114)
at com.sforce.async.BulkConnection.createJob(BulkConnection.java:89)
at com.ngrid.css.CSSCustInfoToGF.createJob(CSSCustInfoToGF.java:1233)
at com.ngrid.css.CSSCustInfoToGF.uploadBatchToBulkAPI(CSSCustInfoToGF.java:1106)
at com.ngrid.css.CSSCustInfoToGF.mapCSSAccountRequest(CSSCustInfoToGF.java:361)
at com.ngrid.css.CSSCustInfoToGF.onMessage(CSSCustInfoToGF.java:151)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1011)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:175)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2928)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4019)
at com.sun.ejb.containers.MessageBeanContainer.deliverMessage(MessageBeanContainer.java:1111)
at com.sun.ejb.containers.MessageBeanListenerImpl.deliverMessage(MessageBeanListenerImpl.java:74)
at com.sun.enterprise.connectors.inflow.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:179)
at com.sun.proxy.$Proxy69.onMessage(Unknown Source)
at com.stc.jmsjca.core.XMessageEndpoint.onMessage(XMessageEndpoint.java:60)
at com.stc.jmsjca.core.Delivery.deliverToEndpoint(Delivery.java:1068)
at com.stc.jmsjca.core.SerialDelivery.onMessage(SerialDelivery.java:253)
at com.stc.jms.client.SessionImpl.processAsyncDataAvailable(SessionImpl.java:1661)
at com.stc.jms.client.SessionImpl.processAsync(SessionImpl.java:1750)
at com.stc.jms.client.SessionImpl.asyncEnter(SessionImpl.java:1778)
at com.stc.jms.client.SessionImpl.access$500(SessionImpl.java:56)
at com.stc.jms.client.SessionImpl$1.run(SessionImpl.java:1556)
at com.stc.jms.client.SessionImpl$2.run(SessionImpl.java:1809)
at java.lang.Thread.run(Thread.java:761)
Caused by:
java.net.UnknownHostException: cs9.salesforce.com
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:253)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:376)
at java.net.Socket.connect(Socket.java:546)
at com.ibm.jsse2.SSLSocketImpl.connect(SSLSocketImpl.java:11)
at com.ibm.jsse2.dd.connect(dd.java:83)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:437)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:551)
at com.ibm.net.ssl.www2.protocol.https.c.<init>(c.java:116)
at com.ibm.net.ssl.www2.protocol.https.c.a(c.java:105)
at com.ibm.net.ssl.www2.protocol.https.d.getNewHttpClient(d.java:12)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:978)
at com.ibm.net.ssl.www2.protocol.https.d.connect(d.java:43)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1043)
at com.ibm.net.ssl.www2.protocol.https.b.getOutputStream(b.java:71)
at com.sforce.ws.transport.JdkHttpTransport.connectRaw(JdkHttpTransport.java:115)
at com.sforce.ws.transport.JdkHttpTransport.connect(JdkHttpTransport.java:79)
at com.sforce.async.BulkConnection.createOrUpdateJob(BulkConnection.java:95)
... 27 more

This is the connection code:

private BulkConnection getBulkConnection(String userName, String password)
throws ConnectionException, AsyncApiException {
asyncErrorMsg = "Exception occured while establishing the connection";
ConnectorConfig partnerConfig = new ConnectorConfig();

partnerConfig.setUsername(userName);
partnerConfig.setPassword(password);
partnerConfig.setConnectionTimeout(Integer.parseInt(System.getProperty("ConnectionTimeOut")));

partnerConfig.setAuthEndpoint(System.getProperty("GFEndPoint"));
// Creating the connection automatically handles login and stores
// the session in partnerConfig
new PartnerConnection(partnerConfig);
// When PartnerConnection is instantiated, a login is implicitly
// executed and, if successful,
// a valid session is stored in the ConnectorConfig instance.
// Use this key to initialize a BulkConnection:
ConnectorConfig config = new ConnectorConfig();
config.setSessionId(partnerConfig.getSessionId());
// The endpoint for the Bulk API service is the same as for the normal
// SOAP uri until the /Soap/ part. From here it's '/async/versionNumber'
String soapEndpoint = partnerConfig.getServiceEndpoint();
String apiVersion = "30.0";
String restEndpoint = soapEndpoint.substring(0, soapEndpoint.indexOf("Soap/")) + "async/" + apiVersion;
config.setRestEndpoint(restEndpoint);
// This should only be false when doing debugging.
config.setCompression(true);
// Set this to true to see HTTP requests and responses on stdout
config.setTraceMessage(false);
BulkConnection connection = new BulkConnection(config);
return connection;
}
Ashish_SFDC Ashish_SFDC
Hi ,


That is related with

hostname

and

/etc/hosts

If /etc/hosts doesn't containt the definition of the hostname it fails. Just add your hostname to /etc/host for example if your hostname is work add or modified the following line:

127.0.0.1   work        localhost

http://stackoverflow.com/questions/4969156/error-java-net-unknownhostexception


If network policies prevent access to login.salesforce.com, use a proxy server to connect.  Proxy server connection information can be obtained from your organization's Corporate IT / Networking group.

http://knowledgebase.progress.com/articles/Article/Error-on-test-connect-to-Salesforce-java-net-UnknownHostException


Also see below articles for more information,

http://docs.oracle.com/javase/1.5.0/docs/guide/net/proxies.html

https://blogs.oracle.com/sravansarraju/entry/wildcard_ssl_certificate_support_in


Regards,
Ashish