9/05/2012

grails ไม่สามารถ resolve hostname ได้

ตอนสั่ง grails run-app กลับเจอ Exception


| Running Grails application
ehcache.Cache Unable to set localhost. This prevents creation of a GUID. Cause was: Thanabodee.local: Thanabodee.local: nodename nor servname provided, or not known
java.net.UnknownHostException: Thanabodee.local: Thanabodee.local: nodename nor servname provided, or not known
at java.net.InetAddress.getLocalHost(InetAddress.java:1438)
at net.sf.ehcache.Cache.<clinit>(Cache.java:200)
at net.sf.ehcache.config.ConfigurationHelper.createCache(ConfigurationHelper.java:302)
at net.sf.ehcache.config.ConfigurationHelper.createDefaultCache(ConfigurationHelper.java:218)
at net.sf.ehcache.CacheManager.configure(CacheManager.java:618)
at net.sf.ehcache.CacheManager.init(CacheManager.java:361)
at net.sf.ehcache.CacheManager.<init>(CacheManager.java:230)
at net.sf.ehcache.hibernate.EhCacheRegionFactory.start(EhCacheRegionFactory.java:70)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.net.UnknownHostException: Thanabodee.local: nodename nor servname provided, or not known
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:866)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1258)
at java.net.InetAddress.getLocalHost(InetAddress.java:1434)
... 12 more
[localhost].[/todo] StandardWrapper.Throwable
org.h2.message.DbException: IO Exception: "java.net.UnknownHostException: Thanabodee.local: Thanabodee.local: nodename nor servname provided, or not known" [90028-168]
at org.h2.message.DbException.get(DbException.java:158)
at org.h2.message.DbException.convert(DbException.java:273)
at org.h2.util.NetUtils.getLocalAddress(NetUtils.java:263)
at org.h2.server.web.WebServer.updateURL(WebServer.java:325)
at org.h2.server.web.WebServer.init(WebServer.java:315)
at org.h2.server.web.WebServlet.init(WebServlet.java:51)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5015)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5302)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.h2.jdbc.JdbcSQLException: IO Exception: "java.net.UnknownHostException: Thanabodee.local: Thanabodee.local: nodename nor servname provided, or not known" [90028-168]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
... 20 more
Caused by: java.net.UnknownHostException: Thanabodee.local: Thanabodee.local: nodename nor servname provided, or not known
at java.net.InetAddress.getLocalHost(InetAddress.java:1438)
at org.h2.util.NetUtils.getLocalAddress(NetUtils.java:261)
... 17 more
Caused by: java.net.UnknownHostException: Thanabodee.local: nodename nor servname provided, or not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:866)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1258)
at java.net.InetAddress.getLocalHost(InetAddress.java:1434)
... 18 more
[localhost].[/todo] Servlet /todo threw load() exception
java.net.UnknownHostException: Thanabodee.local: nodename nor servname provided, or not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:866)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1258)
at java.net.InetAddress.getLocalHost(InetAddress.java:1434)
at org.h2.util.NetUtils.getLocalAddress(NetUtils.java:261)
at org.h2.server.web.WebServer.updateURL(WebServer.java:325)
at org.h2.server.web.WebServer.init(WebServer.java:315)
at org.h2.server.web.WebServlet.init(WebServlet.java:51)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5015)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5302)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
| Server running. Browse to http://localhost:8080/todo

เข้าใจว่ามันต่อเข้าไปที่ Thanabodee.local แต่มันหาไม่เจอเลยยิง Exception นี้ออกมาวิธีแก้คือไป /etc/hosts และแก้ไขในไฟล์

127.0.0.1 localhost Thanabodee.local
::1       localhost Thanabodee.local

restart network หลังจากนั้นก็ใช้ได้เลย