I have a project in eclipse to retrieve data from a certain website. As there is too much data to be retrieved I have to keep the code running overnight. I get ajave.net.UnknownHostException
after sometime. The code runs without any problem for a long time and only later the UnknownHostexception
occurs. Any solution as to why this is happening?

- 93
- 2
- 7
3 Answers
You can only have the mac address of your server where the war is being deployed, Check it here how to get the MAC address

- 237,923
- 42
- 401
- 438
I have seen this error in one of my projects before. Till Java 1.5, JVM used to cache the DNS entry and did not honor the TTL values. If for some reason, the DNS entry was modified (usually the case with Akamai or other CDN networks), and the IP you were going to before is no longer available, you may hit upon this error.
Some info on this behavior is available at http://www.rgagnon.com/javadetails/java-0445.html and http://blog.andrewbeacock.com/2006/12/warning-java-caches-dns-to-ip-address.html.
What you may try is to run a iptrace when it works fine and when it starts failing from the same machine - if the IP has changed, you are hitting this scenario.

- 2,396
- 3
- 23
- 37
-
I have changed my java.security file as mentioned in the blog. Will repost if I am facing the problem again. Thank You. – Thal Jul 16 '12 at 07:02
My guess is that your internet connect is probably breaking. Do you have any other logs to verify this?

- 8,238
- 7
- 36
- 53
-
I do not have any other logs. I try with sangupta's answer and see if it works fine. – Thal Jul 16 '12 at 07:00