Linux环境下C3P0 Failed to get local InetAddress for VMID 解决办法
2014-08-20 11:49
459 查看
今天在做一个Java项目中用到了C3P0数据源,程序在Windows下运行没有任何问题,但是往服务器(Linux环境)上部署 运行的时候出现异常了,异常信息如下:
2014-08-19 20:51:01 [INFO] Failed to get local InetAddress for VMID. This is unlikely to matter. At all. We'll add some extra randomness
java.net.UnknownHostException: w: w
at java.net.InetAddress.getLocalHost(Unknown Source)
at com.mchange.v2.c3p0.impl.C3P0ImplUtils.generateVmId(C3P0ImplUtils.java:120)
at com.mchange.v2.c3p0.impl.C3P0ImplUtils.<clinit>(C3P0ImplUtils.java:98)
at com.mchange.v2.c3p0.impl.PoolBackedDataSourceBase.<init>(PoolBackedDataSourceBase.java:227)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.<init>(AbstractPoolBackedDataSource.java:62)
at com.mchange.v2.c3p0.ComboPooledDataSource.<init>(ComboPooledDataSource.java:109)
at com.mchange.v2.c3p0.ComboPooledDataSource.<init>(ComboPooledDataSource.java:105)
.......
Caused by: java.net.UnknownHostException: w
at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(Unknown Source)
at java.net.InetAddress.getAddressesFromNameService(Unknown Source)
... 23 more
乍一看感觉莫名其妙,从来都没碰到过这样的异常,最后在Google上找到了解决办法,先说明一下导致这个异常的原因,然后给出解决办法。
问题原因
先看看UnknownHostException: w 中w是怎么得来的吧,cat /etc/sysconfig/network 文件,内容如下:
[root@w picture]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=w
HOSTNAME=w,噢噢,看到这里顿时感觉 柳暗花明了,原来是因为系统没有找到主机名w对应的IP,只需修改Linux的hosts文件即可。
解决办法
上面已经分析错误原因了,主要是因为系统没有找到主机名w对应的IP,修改Linux的hosts文件即可。具体操作步骤如下:
首先,执行 cat /etc/hosts 命令,如下:
[root@w picture]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
然后再执行 vi /etc/hosts 命令
在第一行 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 后加上 w 保存即可。
修改完之后的hosts文件如下:
[root@w picture]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 w
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
Linux查找域名时通常指先查找文件/etc/hosts,找不到时再向DNS服务器请求。
OK,到这里 问题已经搞定了!
2014-08-19 20:51:01 [INFO] Failed to get local InetAddress for VMID. This is unlikely to matter. At all. We'll add some extra randomness
java.net.UnknownHostException: w: w
at java.net.InetAddress.getLocalHost(Unknown Source)
at com.mchange.v2.c3p0.impl.C3P0ImplUtils.generateVmId(C3P0ImplUtils.java:120)
at com.mchange.v2.c3p0.impl.C3P0ImplUtils.<clinit>(C3P0ImplUtils.java:98)
at com.mchange.v2.c3p0.impl.PoolBackedDataSourceBase.<init>(PoolBackedDataSourceBase.java:227)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.<init>(AbstractPoolBackedDataSource.java:62)
at com.mchange.v2.c3p0.ComboPooledDataSource.<init>(ComboPooledDataSource.java:109)
at com.mchange.v2.c3p0.ComboPooledDataSource.<init>(ComboPooledDataSource.java:105)
.......
Caused by: java.net.UnknownHostException: w
at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(Unknown Source)
at java.net.InetAddress.getAddressesFromNameService(Unknown Source)
... 23 more
乍一看感觉莫名其妙,从来都没碰到过这样的异常,最后在Google上找到了解决办法,先说明一下导致这个异常的原因,然后给出解决办法。
问题原因
先看看UnknownHostException: w 中w是怎么得来的吧,cat /etc/sysconfig/network 文件,内容如下:
[root@w picture]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=w
HOSTNAME=w,噢噢,看到这里顿时感觉 柳暗花明了,原来是因为系统没有找到主机名w对应的IP,只需修改Linux的hosts文件即可。
解决办法
上面已经分析错误原因了,主要是因为系统没有找到主机名w对应的IP,修改Linux的hosts文件即可。具体操作步骤如下:
首先,执行 cat /etc/hosts 命令,如下:
[root@w picture]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
然后再执行 vi /etc/hosts 命令
在第一行 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 后加上 w 保存即可。
修改完之后的hosts文件如下:
[root@w picture]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 w
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
Linux查找域名时通常指先查找文件/etc/hosts,找不到时再向DNS服务器请求。
OK,到这里 问题已经搞定了!
相关文章推荐
- C3P0在Linux下的Failed to get local InetAddress for VMID解决方法
- Failed to get local InetAddress for VMID
- Failed to get local InetAddress for VMID. This is unlikely to matter.
- Failed to get local InetAddress for VMID. This is unlikely to matter.
- ios在真机上调试时出现“Error launching remote program: failed to get the task for process xxx"解决办法
- Linux Apache 启动时错误httpd: apr_sockaddr_info_get() failed for host.localdomain解决记录
- [xcode]Error launching remote program: failed to get the task for process xxx 本人解决办法
- ios在真机上调试时出现“Error launching remote program: failed to get the task for process xxx"解决办法(转)
- ios在真机上调试时出现“Error launching remote program: failed to get the task for process xxx"解决办法(转)
- InetAddress.getLocalHost().getHostAddress()在window下正常运行,在linux下报运行时异常的解决办法
- Error for wireless request "Set AP Address" (8B14) : SET failed on device wlan0 错误解决办法
- linux 下apche无法监听端口解决办法(Permission denied: make_sock: could not bind to address)
- failed to get the task for process 1363问题解决
- XCode4.5免证书真机调试解决 failed to get the task for process xxx
- apt-get update 时的问题 W:Failed to fetch gzip:/var/lib/apt/lists/partial...解决办法
- 64位win7环境MyEclipse集成svn后出现Failed to load JavaHL Library的解决办法
- Error launching remote program: failed to get the task for process 10722.The解决方法
- filezilla Failed to create listen socket on port 21 for IPv4 解决办法
- FreeBSD和linux下解决apache错误:apr_sockaddr_info_get() failed for freebsdla
- android sdk for windows出现A folder failed to be renamed or moved 解决办法