物竞天择 适者生存

我们不是代码的搬运工,我们只生产代码

Linux环境下C3P0 Failed to get local InetAddress for VMID 解决办法

今天在做一个spring boot项目中用到了C3P0数据源,程序在Mac下运行没有任何问题,但是往服务器Linux(Centos 环境)上部署 运行的时候出现异常了,异常信息如下:

2018-03-16 12:42:56.185  [INFO] Failed to get local InetAddress for VMID. This is unlikely to matter. At all. We'll add some extra randomness  
java.net.UnknownHostException: XSY: XSY  
    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  

找不到XSY主机

看一下network文件

[root@XSY ~]# cat /etc/sysconfig/network  
NETWORKING=yes
HOSTNAME=XSY

再看看hosts 文件

127.0.0.1  localhost  localhost.localdomain  centos_v4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

问题找到了

找不到XSY的host记录

加一条就好了

127.0.0.1  XSY

保存hosts文件, 问题完美解决

点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注