[INFO ] 2018-04-09 18:35:44,946 method:org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:285)
Root WebApplicationContext: initialization started
[INFO ] 2018-04-09 18:35:45,010 method:org.springframework.context.support.AbstractApplicationContext.prepareRefresh(AbstractApplicationContext.java:510)
Refreshing Root WebApplicationContext: startup date [Mon Apr 09 18:35:45 CST 2018]; root of context hierarchy
[INFO ] 2018-04-09 18:35:45,046 method:org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:317)
Loading XML bean definitions from file [/usr/java/apache-tomcat-7.0.57/webapps/ROOT/WEB-INF/classes/spring/applicationContext-trans.xml]
[INFO ] 2018-04-09 18:35:45,174 method:org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:317)
Loading XML bean definitions from file [/usr/java/apache-tomcat-7.0.57/webapps/ROOT/WEB-INF/classes/spring/applicationContext-dao.xml]
[INFO ] 2018-04-09 18:35:45,211 method:org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:317)
Loading XML bean definitions from file [/usr/java/apache-tomcat-7.0.57/webapps/ROOT/WEB-INF/classes/spring/applicationContext-service.xml]
[INFO ] 2018-04-09 18:35:45,373 method:org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:172)
Loading properties file from file [/usr/java/apache-tomcat-7.0.57/webapps/ROOT/WEB-INF/classes/resources/db.properties]
[INFO ] 2018-04-09 18:35:45,374 method:org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:172)
Loading properties file from file [/usr/java/apache-tomcat-7.0.57/webapps/ROOT/WEB-INF/classes/resources/resource.properties]
[INFO ] 2018-04-09 18:35:45,967 method:org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
Root WebApplicationContext: initialization completed in 1019 ms
我的tomcat7到这里就不动了,找了大量资料还是没有解决。过了大半天忽然发现tomcat启动起来了。
就改变了搜索策略,tomcat启动慢怎么办
查阅大量资料发现是由于tomcat启动时产生随机数导致jvm阻塞,可能是我多次重启tomcat导致熵池被用空造成阻塞。。
在apache-tomcat官方文档:如何让tomcat启动更快里面提到了一些启动时的优化项,其中一项是关于随机数生成时,采用的“熵源”(entropy source)的策略。他提到tomcat7的session id的生成主要通过java.security.SecureRandom生成随机数来实现,随机数算法使用的是”SHA1PRNG”
有两种解决方式
1)配置tomcat参数
可以通过配置JRE使用非阻塞的Entropy Source。
在catalina.sh中加入这么一行:-Djava.security.egd=file:/dev/./urandom 即可。
加入后再启动Tomcat,整个启动耗时下降到Server startup in 2912 ms。
2)在JVM环境中解
打开$JAVA_PATH/jre/lib/security/java.security这个文件,找到下面的内容:
securerandom.source=file:/dev/urandom大概在70行 ,替换成
securerandom.source=file:/dev/./urandom