Why does java.net.UnknownHostException require cha

2019-06-24 06:31发布

In regards to this question Play Framework GUID why do I have to change my hosts file? I was having a similar issue while running a test in fedora which returned the following error

[error] (*:testListeners) java.net.UnknownHostException: fedora: fedora: Name 
or service not known

I added the line

127.0.0.1 localhost fedora

to my /etc/hosts file, which fixed this, but why should this have to be done in the first place?

1条回答
Ridiculous、
2楼-- · 2019-06-24 06:47

Play server loads EhCache. When EhCache is loaded (specifically net.sf.ehcache.Cache) it attempts to determine the address for localhost which is used in a process to create GUIDs identifying the cache instances created. EhCache does this by calling InetAddress.getLocalHost(). This method searches your host file for an entry matching the hostname set for the local machine, if it doesn't find one it throws an UnknownHostException.

The fix, as demonstrated in an answer to the question you linked, is to set a host entry for the local hostname.

查看更多
登录 后发表回答