部署某个旧项目时候,发现启动特别慢,要等好几分钟。然后每次部署都停留在
At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
jdk环境是1.8,tomcat版本是8.0.
上下文日志:
securerandom.source=file:/dev/./urandom
15-Nov-2018 09:56:13.331 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
15-Nov-2018 09:59:29.043 WARNING [localhost-startStop-1] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [195,690] milliseconds.
可以看到,就是这个:
Creation of SecureRandom instance
导致了启动时间变长。
解决方案有两个:
1)在Tomcat环境中解决
可以通过配置JRE使用非阻塞的Entropy Source。
在catalina.sh中加入这么一行:
-Djava.security.egd=file:/dev/./urandom
即可。
2)在JVM环境中解决
打开$JAVA_PATH/jre/lib/security/java.security这个文件,找到下面的内容:
securerandom.source=file:/dev/urandom
替换成
securerandom.source=file:/dev/./urandom