hostname -i和hostname -a解析不出来引起java错误

错误信息
SEVERE: StandardServer.await: create[ 8005 ]:
java.net.UnknownHostException: localhost: localhost
at java.net.InetAddress.getAllByName0(InetAddress.java:1128 )
at java.net.InetAddress.getAllByName0(InetAddress.java:1098 )
at java.net.InetAddress.getAllByName(InetAddress.java:1061 )
at java.net.InetAddress.getByName(InetAddress.java:958 )
at org.apache.catalina.core.StandardServer.await(StandardServer.java:373 )
at org.apache.catalina.startup.Catalina.await(Catalina.java:642 )
at org.apache.catalina.startup.Catalina.start(Catalina.java:602 )
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 )
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25 )
at java.lang.reflect.Method.invoke(Method.java:585 )
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288 )
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413 )
SEVERE: StandardServer.await: create[8005]:
java.net.UnknownHostException: localhost: localhost
at java.net.InetAddress.getAllByName0(InetAddress.java:1128)
at java.net.InetAddress.getAllByName0(InetAddress.java:1098)
at java.net.InetAddress.getAllByName(InetAddress.java:1061)
at java.net.InetAddress.getByName(InetAddress.java:958)
at org.apache.catalina.core.StandardServer.await(StandardServer.java:373)
at org.apache.catalina.startup.Catalina.await(Catalina.java:642)
at org.apache.catalina.startup.Catalina.start(Catalina.java:602)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
 


测试方案:
ping 127.0.0.1 可以ping通
ping localhost 不通

说明是主机映射的原因。

解决方法:
修改etc/hosts 文件
[oracle@bogon ~]$ su - root
Password:
[root@bogon ~]# cd ..
[root@bogon /]# cd ..
[root@bogon /]# cd etc
[root@bogon etc]# cat hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 bogon.localdomain bogon

在hosts文件中追加下面一行就OK了:
127.0.0.1 localhost.localdomain localhost

修改/etc/hosts和/etc/sysconfig/network

要求用hostname -a和hostname -i可以解析出IP和主机名

你可能感兴趣的:(hostname,hostname,java错误,-I,-a解析不出来)