-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

0

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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
For question no2, no we are not replacing the url
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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.