13

I am new to webservices and trying to write a RESTFul webservice's client using RestTemplate. I am using org.springframework.http.converter.xml.MarshallingHttpMessageConverter as message converter and org.springframework.oxm.xstream.XStreamMarshaller as marshaller.

Is there any way to debug this further or find out the root cause of this issue?

My consumer class looks like this -

@SuppressWarnings("unchecked")
public List<Deal> getClientInformation() throws RestClientException {
    return restTemplate.getForObject(webServiceURL, List.class);

}

Exception :

Exception in thread "main" org.springframework.web.client.ResourceAccessException: I/O error: Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:359)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:307)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:177)
at main.java.com.sample.consumer.DealConsumer.getClientInformation(Consumer.java:35)
at main.java.com.client.WebserviceConsumerTestClient.main(WebserviceConsumerTestClient.java:16)

Caused by: java.net.ConnectException: Connection refused: connect at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:359)

Bruso
  • 803
  • 3
  • 12
  • 25

1 Answers1

24

the webServiceURL you are trying to call is not reachable. Ensure the webServiceURL path is correct and is listening.

PS. Also check if there is some firewall issue at Server side.

Wireshark may help you to debug further.

http://www.wireshark.org/

dhamibirendra
  • 3,016
  • 23
  • 26
  • 4
    thanks yes it was firewall issue. I was able to get through this error by adding below two lines before hitting the webservice in the client code. System.setProperty("proxyHost", "yourproxy.server.com"); System.setProperty("proxyPort", "8080"); – Bruso Jul 25 '12 at 11:51
  • 2
    well great than, now if the issue is solved, you could close this question by marking the answer as correct. – dhamibirendra Jul 25 '12 at 11:58
  • @dhamibirendra what to do in case of intermittent error for "org.springframework.web.client.ResourceAccessException: I/O error on GET request for "": connect timed out; nested exception is java.net.SocketTimeoutException" – Sam Mar 29 '17 at 04:33
  • @Sam, Seems the URL that you are trying to connect is not reachable. Can you ping the URL? If that URL is unreachable, then contact your network admin or the person responsible for exposing of the URL to your system. – dhamibirendra Mar 29 '17 at 12:18
  • @dhamibirendra Thank you both – mtbadi39 Nov 05 '18 at 15:17