在服务器上执行关闭Tomcat命令是出现下面的错误信息
[[email protected] classes]# service tomcat restart Stopping Tomcat service: Using CATALINA_BASE: /opt/tomcat Using CATALINA_HOME: /opt/tomcat Using CATALINA_TMPDIR: /opt/tomcat/temp Using JRE_HOME: /usr Apr 17, 2011 10:11:53 PM org.apache.catalina.startup.Catalina stopServer SEVERE: Catalina.stop: java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:310) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:176) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:163) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:381) at java.net.Socket.connect(Socket.java:537) at java.net.Socket.connect(Socket.java:487) at java.net.Socket.<init>(Socket.java:384) at java.net.Socket.<init>(Socket.java:198) at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:421) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:337) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)
然后排查相关信息,在Stack Overflow网站上上面说可能是CentOS防火墙的问题,查看防火墙配置文件,8005端口已经配置好了。然后关闭防火墙,依然是Connection refused
然后使用telnet命令测试。首先测试telnet 127.0.0.1 80,正常然后telnet 127.0.0.1 8005,正常,后来测试telnet localhost 80,异常出现Connection refused,telnet localhost 8005,也是异常,Connection refused。
应该就是localhost解析的问题了。
#vim /etc/hosts
查看本地hosts配置文件。
127.0.0.1 IT2YWMHA01 localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
修改localhost,将其添加到127.0.0.1下面,修改后为
127.0.0.1 IT2YWMHA01 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost.localdomain localhost6 localhost6.localdomain6
测试#sh shutdown.sh,现在可以正常关闭Tomcat,不再提示Connection refused。
时间: 2024-12-14 08:16:06