在用centos7.+不熟tomcat项目的时候,启动时突然很奇怪的没报错,但是又访问不了网址,调用
./shutdown.sh
又结束不了,一直出现:
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:498)
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:343)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:430)
一定要用kill命令才结束地了:
ps -aux | grep java
kill -9 19562
后面查了相关博客才发现,其实是centos7.+本身安全性的问题,需要改安装jdk源文件,找到java.security :
vi /usr/java/default/jre/lib/security/java.security
中的
securerandom.source=file:/dev/urandom
改成:
securerandom.source=file:/dev/./urandom
即可解决问题