嗨,我正在尝试关闭和启动 tomcat 服务器。但是我在运行shutdown.sh时遇到错误。请检查以下错误并建议我完成。

错误:

Using CATALINA_BASE:   /opt/tomcat8
Using CATALINA_HOME:   /opt/tomcat8
Using CATALINA_TMPDIR: /opt/tomcat8/temp
Using JRE_HOME:        /usr/java/jdk1.8.0_74
Using CLASSPATH:       /opt/tomcat8/bin/bootstrap.jar:/opt/tomcat8/bin/tomcat-ju                                                                                        li.jar
Jul 24, 2017 11:01:47 PM org.apache.catalina.startup.Catalina stopServer
SEVERE: Could not contact localhost:8005. Tomcat may not be running.
Jul 24, 2017 11:01:48 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.ja                                                                                        va:350)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocket                                                                                        Impl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java                                                                                        :188)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:589)
        at java.net.Socket.connect(Socket.java:538)
        at java.net.Socket.<init>(Socket.java:434)
        at java.net.Socket.<init>(Socket.java:211)

另请查找日志:
24-Jul-2017 23:48:28.884 SEVERE [main] org.apache.catalina.core.StandardServer.await StandardServer.await: create[localhost:8005]:
 java.net.BindException: Address already in use
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
    at java.net.ServerSocket.bind(ServerSocket.java:375)
    at java.net.ServerSocket.<init>(ServerSocket.java:237)
    at org.apache.catalina.core.StandardServer.await(StandardServer.java:420)
    at org.apache.catalina.startup.Catalina.await(Catalina.java:717)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:663)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)

24-Jul-2017 23:48:28.884 INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8082"]
24-Jul-2017 23:48:28.884 INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-nio-8009"]
24-Jul-2017 23:48:28.884 INFO [main] org.apache.catalina.core.StandardService.stopInternal Stopping service Catalina
24-Jul-2017 23:48:28.988 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8082"]
24-Jul-2017 23:48:28.990 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8082"]
24-Jul-2017 23:48:28.992 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-nio-8009"]
24-Jul-2017 23:48:28.992 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-nio-8009"]

最佳答案

由于 tomcat 无法在端口上绑定(bind)网络,因此在端口 8005 上运行了一些应用程序。您的 shutdown.sh 将抛出异常,因为服务器尚未启动(因为启动服务器时出现问题)

  • 方案一(推荐):将/opt/tomcat8/conf/server.xml中的8005端口改为8006
  • 解决方案2:请通过netstat -tulnp | grep 8005检查哪个应用程序正在使用8005并将其关闭。
  • 关于java - 无法联系本地主机 :8005. Tomcat 在关闭 tomcat 时可能不会运行错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45296070/

    10-10 13:36