出错环境介绍:
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
报错如上所描述
报错信息提到连接被拒绝,可能是Tomcat没有在运行,网上搜索相关资料说原因好像是JDK8的bug
解决方案一:直接修改JDK配置(不推荐)
解决办法二:修改cataline.sh
的内容:文件头部添加一行指令
JAVA_OPTS=-Djava.security.egd=file:/dev/./urandom