Question:

Please help: java InetAddress.getAllByName unexpected result for cia.gov?

by  |  earlier

0 LIKES UnLike

I can do an nslookup of cia.gov or google.com or whatever and I can browse the web with no trouble. However, when I attempt to look up these same sites with java.net.InetAddress.getAllByName I get an UnknownHost exception. I am not sure how to diagnose this. Where do I start?

#nslookup cia.gov

Server: 205.152.144.23

Address: 205.152.144.23#53

Non-authoritative answer:

Name: cia.gov

Address: 198.81.129.100

try {

InetAddress [] inetAddresses = InetAddress.getAllByName("cia.gov");

} catch (UnknownHostException e1) {

e1.printStackTrace();

System.exit(0);

}

java.net.UnknownHostException: cia.gov

at java.net.Inet6AddressImpl.lookupAllHostA... Method)

at java.net.InetAddress$1.lookupAllHostAddr...

at java.net.InetAddress.getAddressFromNameS...

at java.net.InetAddress.getAllByName0(InetA...

at java.net.InetAddress.getAllByName(InetAd...

at java.net.InetAddress.getAllByName(InetAd...

 Tags:

   Report

2 ANSWERS


  1. Do you have a proxy server in your network?  Might be related to that as I don't believe Java picks up the system proxy value (unfortunately I haven't had to deal with external resources with any of my Java development).  Given the UnknownHostException, it really sounds like it can't resolve the hostname so that's why I'm thinking proxy related.

    ** Edit **

    Have you tried by using the IP address then instead of the hostname?  The method will accept an IP address.  I know this isn't what you would ideally like, but as part of the troubleshooting, it might identify if this is an access, resolution, or a procedural issue.

    ** Edit 2 **

    Thanks for the tip on UClue, I wasn't aware that it existed.


  2. Personally, *I* would not be messing around with cia.gov searches ;)

    Just sayin'

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions