Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.net.UnknownHostException

I'm installing CSVN using jdk1.6.0_23 and I'm getting the following Java error:

2011-02-10 16:25:50,951 [WrapperJarAppMain] WARN util.GrailsUtil - [WARNING] Property [ldapServerPort] of domain class com.collabnet.svnedge.console.Server has type [int] and doesn't support constraint [nullable]. This constraint will not be checked during validation. 2011-02-10 16:25:51,117 [WrapperJarAppMain] ERROR ehcache.Cache - Unable to set localhost. This prevents creation of a GUID. Cause was: vkqgae01: vkqgae01 java.net.UnknownHostException: vkqgae01: vkqgae01 at java.net.InetAddress.getLocalHost(InetAddress.java:1354) at net.sf.ehcache.Cache.<clinit>(Cache.java:143) 

My server has 3 NICs (eth0, eth1 and eth2). I've added an entry to the hosts file bellow localhost containing the following:

127.0.0.1 vkqgae01 

I can successfully ping vkqgae01, but nslookup cannot resolve it.

Any ideas?

like image 654
Gilberto Ribeiro Avatar asked Feb 11 '11 12:02

Gilberto Ribeiro


People also ask

What is Java net UnknownHostException?

UnknownHostException is a common error message in Java applications. This error typically indicates that there was a DNS resolution failure. If a Java application fails to get a valid DNS answer, then it might throw an UnknownHostException error.

How do I fix Java net UnknownHostException?

A few tips to prevent the exception are: Double-check the hostname: Make sure there is no typo, and trim all whitespaces. Check the system's DNS settings: Make sure the DNS server is up and reachable, and if the hostname is new, wait for the DNS server to catch up.


2 Answers

That is related with

hostname

and

/etc/hosts

If /etc/hosts doesn't containt the definition of the hostname it fails. Just add your hostname to /etc/host for example if your hostname is work add or modified the following line:

127.0.0.1   work        localhost 
like image 153
atomsfat Avatar answered Sep 21 '22 12:09

atomsfat


I can succesfully ping vkqgae01, but nslookup cannot resolve it.

Any ideas?

What happens?

  • vkqgae01 is resolved locally thanks to your hosts file.
  • nslookup sends a query to your DNS, where vkqgae01 is unknown.


Suggestion: add vkqgae01 to hosts file of every machine where you "use" it.
Basically, the fact that the local hosts file on vkqgae01 contains 127.0.0.1 localhost vkqgae01 doesn't help other machines to solve its name.

like image 28
Destroyica Avatar answered Sep 21 '22 12:09

Destroyica