我的 Tomcat 应用程序部署启动非常慢。
环境:
操作系统:Scientific Linux 6.3 x86_64
Java:1.7.0_9 64位
Tomcat:7.0.32
启动耗时 150 秒,java 进程占用了 100% CPU
我在另一台服务器上尝试了相同的 webapp(具有相同的硬件参数),但在 32 位操作系统上,使用 java6 32 位和 tomcat 7.0.19,并且在此服务器上,tomcat 在 30 秒内启动。
我在新服务器上尝试了相同的 java 和相同的 tomcat,但没有成功。
这是 tomcat 等待某件事时的部分日志...
FINE: Setting state for [WebappLoader[]] to [STARTING]
Nov 19, 2012 1:23:13 PM org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [WebappLoader[]] to [STARTED]
Nov 19, 2012 1:24:06 PM org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for StandardEngine[Catalina].StandardHost[localhost].StandardContext[].StandardWrapper[starthead]] to [INITIALIZING]
...
Nov 19, 2012 1:24:06 PM org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [StandardEngine[Catalina].StandardHost[localhost].StandardContext[].StandardWrapper[default]] to [STARTED]
Nov 19, 2012 1:24:26 PM org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [org.apache.catalina.deploy.NamingResources@2acd47cb] to [INITIALIZING]
Nov 19, 2012 1:24:26 PM org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [org.apache.catalina.deploy.NamingResources@2acd47cb] to [INITIALIZED]
...
Nov 19, 2012 1:24:26 PM org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [Pipeline[StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]] to [STARTED]
Nov 19, 2012 1:25:23 PM org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [org.apache.catalina.session.StandardManager[]] to [INITIALIZING]
Nov 19, 2012 1:25:23 PM org.apache.catalina.util.LifecycleBase setStateInternal
...
FINE: Setting state for [org.apache.catalina.session.StandardManager[]] to [STARTING]
Nov 19, 2012 1:25:23 PM org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [org.apache.catalina.session.StandardManager[]] to [STARTED]
Nov 19, 2012 1:25:43 PM org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]] to [STARTING]
Nov 19, 2012 1:25:43 PM org.apache.catalina.util.LifecycleBase setStateInternal
那么问题出在哪里呢?
答案1
在 conf/catalina.properties 文件中设置tomcat.util.scan.DefaultJarScanner.jarsToSkip
属性,并配置 jar 不被扫描 TLD 文件。