本人从安装Apache到配置到启动tomcat都一帆风顺,但是startup.sh后想要shutdown.sh关闭tomcat时出现了问题。
启动tomcat成功:
关闭tomcat失败:
SEVERE: Could not contact localhost:8005. Tomcat may not be running.
SEVERE: Catalina.stop:
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at java.net.Socket.<init>(Socket.java:425)
at java.net.Socket.<init>(Socket.java:208)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:450)
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:606)
at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:400)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:487)
然后到网上找了很多方法,例如修改/usr/tomcat/apache-tomcat-8.5.29/bin/catalina.sh文件,重启tomcat,重启服务器...都不成功。(后来觉得是因为本人安装的JDK为1.8,如果JDK为1.7或者1.6,可以参考这种方法:点击打开链接)
后来参考了一篇神奇的博客:点击打开链接
解决方法:找到你的jdk安装的地方,cd进入jdk1.x.x_xx/jre/lib/security,修改文件:vim java.security
在文件中找到securerandom.source这个设置项,将其改为:securerandom.source=file:/dev/./urandom
重启tomcat~解决!