-1

I am trying to call a api in java using rest template, when I run the code I am able to get response from the api but when I deploy the code on my jboss server I am getting unknown host exception error

I am calling a public api using an api in java

Sai
  • 1

1 Answers1

1

as described by you the API is running locally I am assuming.

More details about your error: https://docs.oracle.com/javase/7/docs/api/java/net/UnknownHostException.html

Thrown to indicate that the IP address of a host could not be determined.

Which points to an error with your host (target) configurations. Few points you should look into:

  1. Machine which is running the application can speak to the public API endpoint.
  2. In your code you need to make sure you are not replacing the API endpoint address anywhere in the code.
  3. Application machine can resolve the DNS of the API endpoint

Your app should work fine once these are taken care. Hope this helps. Happy Coding.

sera
  • 31
  • 5
  • For question no 1: yes it can when I am trying to access the api using javascript code ,same server is able to fetch me the response by domain name directly – Sai Nov 23 '22 at 09:52
  • For question no2, no we are not replacing the url – Sai Nov 23 '22 at 09:53
  • For question no 3: since we are getting response using java script code for same api using domain name, yes I guess application is able to resolve dns – Sai Nov 23 '22 at 09:54