您的位置:首页 > 运维架构 > Linux

Linux出现java.net.UnknownHostException异常问题的解决办法

2011-10-20 17:16 841 查看
本来在windows系统上调试mapabc是正常,今天转移到linux就出现问题了,经过反复调试,发现是linux无法访问到http://search1.mapabc.com/sisserver引起的问题。

抛出的异常片段:

java.net.UnknownHostException:search1.mapabc.com

这个异常其实是linux无法解析域名引起的,只要在配置一下这个域名对应的IP地址即可解决。

解决办法:

cd /etc/

vi hosts

输入:

211.151.71.11?? search1.mapabc.com

保存再查看结果:

[root@localhost etc]# more hosts

# Do not remove the following line, or various programs

# that require network functionality will fail.

127.0.0.1?????? localhost.localdomain?? localhost

211.151.71.11?? search1.mapabc.com

然后测试一下域名的连接:

[root@localhost etc]# ping 211.151.71.11

PING 211.151.71.11 (211.151.71.11) 56(84) bytes of data.

64 bytes from 211.151.71.11: icmp_seq=0 ttl=242 time=52.6 ms

64 bytes from 211.151.71.11: icmp_seq=1 ttl=242 time=52.4 ms

--- 211.151.71.11 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1001ms

rtt min/avg/max/mdev = 52.492/52.560/52.628/0.068 ms, pipe 2

可以ping通了

最后测试网站,不再出现同一个问题,成功运行!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐