Could not contact [localhost:8005]. Tomcat may not be running.
阿新 • • 發佈:2020-10-07
出錯環境介紹:
Tomcat-version:8.5.56
JDK-version:1.8.0_152
Linux:CentOS-7
錯誤資訊
sh /opt/apache-tomcat-8.5.56/bin/shutdown.sh Using CATALINA_BASE: /opt/apache-tomcat-8.5.56 Using CATALINA_HOME: /opt/apache-tomcat-8.5.56 Using CATALINA_TMPDIR: /opt/apache-tomcat-8.5.56/temp Using JRE_HOME: /opt/jdk1.8.0_152 Using CLASSPATH: /opt/apache-tomcat-8.5.56/bin/bootstrap.jar:/opt/apache-tomcat-8.5.56/bin/tomcat-juli.jar Oct 07, 2020 3:13:26 PM org.apache.catalina.startup.Catalina stopServer SEVERE: Could not contact [localhost:8005]. Tomcat may not be running. Oct 07, 2020 3:13:26 PM org.apache.catalina.startup.Catalina stopServer SEVERE: Catalina.stop: java.net.ConnectException: Connection refused (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.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) at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:504) 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.stopServer(Bootstrap.java:389) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:479)
啟動Tomcat後顯示資訊正確,提示Tomcat started.然後修改了專案需要重啟Tomcat,執行shutdown.sh
報錯如上所描述
解決參考連結: https://stackoverflow.com/questions/36566401/severe-could-not-contact-localhost8005-tomcat-may-not-be-running-error-while
報錯資訊提到連線被拒絕,可能是Tomcat沒有在執行,網上搜索相關資料說原因好像是JDK8的bug
解決方案一:直接修改JDK配置(不推薦)
解決辦法二:修改cataline.sh
的內容:檔案頭部新增一行指令
JAVA_OPTS=-Djava.security.egd=file:/dev/./urandom