Linux解决java.net.UnknownHostException

引用
部署程序的时候启动出了这个错,查了一下是 /etc/hosts文件的问题
17:46:51,770 ERROR ~ Unable to set localhost. This prevents creation of a GUID. Cause was: wdse57: wdse57: Name or service not known
java.net.UnknownHostException: wdse57: wdse57: Name or service not known
at java.net.InetAddress.getLocalHost(InetAddress.java:1473)
at net.sf.ehcache.Cache.<clinit>(Cache.java:155)
at net.sf.ehcache.config.ConfigurationHelper.createCache(ConfigurationHelper.java:298)
at net.sf.ehcache.config.ConfigurationHelper.createDefaultCache(ConfigurationHelper.java:214)
at net.sf.ehcache.CacheManager.configure(CacheManager.java:552)
at net.sf.ehcache.CacheManager.init(CacheManager.java:323)
at net.sf.ehcache.CacheManager.<init>(CacheManager.java:279)
at net.sf.ehcache.CacheManager.create(CacheManager.java:641)
at play.cache.EhCacheImpl.<init>(EhCacheImpl.java:31)
at play.cache.EhCacheImpl.newInstance(EhCacheImpl.java:41)
at play.cache.Cache.init(Cache.java:241)
at play.Play.start(Play.java:511)
at play.Play.detectChanges(Play.java:618)
at play.Invoker$Invocation.init(Invoker.java:198)
at play.server.PlayHandler$NettyInvocation.init(PlayHandler.java:195)
at play.Invoker$Invocation.run(Invoker.java:276)
at play.server.PlayHandler$NettyInvocation.run(PlayHandler.java:235)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.net.UnknownHostException: wdse57: Name or service not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
at java.net.InetAddress.getLocalHost(InetAddress.java:1469)
... 23 more

引用
解决方法是修改etc/hosts文件
用root用户登陆后 vi /etc/hosts
把 wdse57 = ip 写到hosts里边 :wq 保存后退出 reboot重启后生效
如: 127.0.0.1   wdse57  localhost
这个wdse57不是固定的

猜你喜欢

转载自lingyimu.iteye.com/blog/1977822