错误日志如下:
Aug 02, 2017 3:07:18 PM org.apache.catalina.loader.WebappClassLoaderBase validateJarFile
INFO: validateJarFile(/usr/local/tomcat_8080/webapps/ROOT/WEB-INF/lib/javaee-api-7.0.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
Aug 02, 2017 3:07:18 PM org.apache.catalina.loader.WebappClassLoaderBase validateJarFile
INFO: validateJarFile(/usr/local/tomcat_8080/webapps/ROOT/WEB-INF/lib/tomcat-el-api-8.0.9.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/el/Expression.class
Aug 02, 2017 3:07:23 PM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1095)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1957)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [] due to a StackOverflowError. Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies. The class hierarchy being processed was [org.bouncycastle.asn1.ASN1EncodableVector->org.bouncycastle.asn1.DEREncodableVector->org.bouncycastle.asn1.ASN1EncodableVector]
at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2159)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2105)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1980)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1946)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1931)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1330)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:889)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5479)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more
Aug 02, 2017 3:07:23 PM org.apache.catalina.startup.HostConfig deployWAR
SEVERE: Error deploying web application archive /usr/local/tomcat_8080/webapps/ROOT.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:905)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1095)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1957)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Aug 02, 2017 3:07:23 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /usr/local/tomcat_8080/webapps/ROOT.war has finished in 6,029 ms
Aug 02, 2017 3:07:23 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Aug 02, 2017 3:07:23 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Aug 02, 2017 3:07:23 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 6220 ms
又看到错误信息
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/i386:/lib:/usr/lib
Tomcat有三种运行模式:bio、nio、apr,不同模式下Tomcat的运行效率差别比较大
一、bio(blockingIO)
阻塞式IO,Tomcat6及以前版本默认运行模式,性能非常低下,没有经过任何优化处理。
二、nio(noblocking IO)
三、apr(Apache Portable Runtime)
从操作系统(http://lib.csdn.net/base/operatingsystem)级别来解决异步的IO问题,大幅度的提高性能。
必须要安装apr和native,直接启动就支持apr。
安装apr
apr需要APR库和OpenSSL相关库。
yum install apr-devel openssl-devel
安装apr组件:
tar zxvf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure --prefix=/usr/local/apr
make && make install
安装native
进入Tomcat的bin目录,比如:/usr/local/tomcat8/bin
解压native源码包
tar -zxvf tomcat-native.tar.gz
cd tomcat-native-1.1.32-src/jni/native
./configure--with-apr=/usr/bin/apr-1-config--with-java-home="jdk路径" --with-ssl=yes
make && make install
加载apr的环境变量,使tomcat加载Tomcat Native组件:
vi /etc/profile
添加如下内容:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib
加载环境变量,使其立即生效
source /etc/profile
将tomcat的server.xml配置文件里的SSLEngine设置为off