java.net.UnknownHostException

服务器上tomcat启动时,报如下错误:

 

15:28:06,605 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
15:28:06,607 |-ERROR in ch.qos.logback.core.util.ContextUtil@715ea69f - Failed to get local hostname java.net.UnknownHostException: TW-LG-AICLOUD-APP1: TW-LG-AICLOUD-APP1
        at java.net.UnknownHostException: TW-LG-AICLOUD-APP1: TW-LG-AICLOUD-APP1
        at      at java.net.InetAddress.getLocalHost(InetAddress.java:1354)
        at      at ch.qos.logback.core.util.ContextUtil.getLocalHostName(ContextUtil.java:32)
        at      at ch.qos.logback.core.util.ContextUtil.addHostNameAsProperty(ContextUtil.java:41)
        at      at ch.qos.logback.classic.joran.action.ConfigurationAction.begin(ConfigurationAction.java:56)
        at      at ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:276)
        at      at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:148)
        at      at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:130)
        at      at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:157)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:143)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:106)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:56)
        at      at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
        at      at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148)
        at      at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
        at      at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)

 

 

按网上的说法,修改/etc/hosts文件就可以了,我把/etc/hosts文件改为如下:

 

127.0.0.1  TW-LG-AICLOUD-APP1  localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.250. TW-LG-AICLOUD-APP1

 

同时,/etc/sysconfig/network中的HOSTNAME的值也为TW-LG-AICLOUD-APP1,修改完后,重启网卡,再重启tomcat

 

服务,发现还是报错。看了下别的服务器,别的服务器也是这样配置的。后面一想,会不会是TW-LG-

 

AICLOUD-APP1太长、或者有分隔符,所以换了个简短的主机名,修改为简单的主机名后,还是不行。

 

后面试了下用hostname myhostname修改主机名,重启tomcat,发现生效了。

 

因服务器不能随便重启,估计是因为修改/etc/sysconfig/network和/etc/hosts文件,需要重启机器才能生效。

 

而直接用命令修改,是不需要重启服务器的。但是重启后,会以配置文件的为准。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值