Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

UnknownHostException  RSS feed

 
Bod Toki
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi....

I've got this little problem. Whenever I try to connect to a web resource like this:

...I get a UnknownHostException when i set the urlStr to something like "www.google.com".
...but whenever I attempt a connect with the IP address "72.14.205.147" (the IP address of google I got from a lookup), my connection becomes successful.

Does anybody know whats going wrong? What do you suggest I do to solve this problem... I want to use the url and not the IP address.
It's looking like some DNS issues but I can't quite figure it out or a way to solve the problem. I am running this code in the Glassfish container.

Thanks.
 
Duc Vo
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the server hosting Glassfish, can you ping www.google.com from the console?
 
Paul Clapham
Sheriff
Posts: 22502
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does it work better when you don't leave out the URL protocol? For example, http://www.google.com?
 
Bod Toki
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the server hosting Glassfish, can you ping www.google.com from the console?

Yes I get to ping www.google.com fine on the console.


I am actually using the complete url string including protocol like this: "http://www.google.com".
 
Bod Toki
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys...

tried the code on another PC (behind the same router) and was successful.

I guess it must be some connection configuration problem with the other machine.

(I wonder how I'd fix this).

Thanks.
 
Duc Vo
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bod Toki wrote:
On the server hosting Glassfish, can you ping www.google.com from the console?

Yes I get to ping www.google.com fine on the console.

Can you try again when logging in with the service account which run Glassfish?
Is the service account local account or network account?
 
Bod Toki
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Duc Vo wrote:
Bod Toki wrote:
On the server hosting Glassfish, can you ping www.google.com from the console?

Yes I get to ping www.google.com fine on the console.

Can you try again when logging in with the service account which run Glassfish?
Is the service account local account or network account?


I don't quite understand what you mean by that. I am not too familiar with server administration stuffs. But I guess I never changed it from the defaults I got when I installed it with the Netbeans bundle.
 
Duc Vo
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bod Toki wrote:
I don't quite understand what you mean by that. I am not too familiar with server administration stuffs. But I guess I never changed it from the defaults I got when I installed it with the Netbeans bundle.

I'm not sure what OS you are running so can't comment much. What OS are you running?

If you are using Windows and the server runs as a windows service then you can find the account running it under the service settings (using services.msc). Also the network settings for Java is in the Java Control Panel, you can access it in the Windows Control Panel.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!