org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].Standard
整合SSM框架时,启动tomcat报出如下错误:
-----------------------------------------------------------------------------------------------------------------------
严重: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/zdfg]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1107)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1841)
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:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@4bc5d8eb]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4842)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4974)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more
Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet@5b77f290]
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:112)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:708)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 13 more
Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: invalid LOC header (bad signature)
at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:113)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
... 16 more
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
at java.util.zip.ZipFile.read(Native Method)
at java.util.zip.ZipFile.access$1400(ZipFile.java:60)
at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:717)
at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:419)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
at sun.misc.IOUtils.readFully(IOUtils.java:65)
at java.util.jar.JarFile.getBytes(JarFile.java:425)
at java.util.jar.JarFile.getManifestFromReference(JarFile.java:193)
at java.util.jar.JarFile.getManifest(JarFile.java:180)
at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:111)
... 17 more
三月 07, 2018 7:16:52 下午 org.apache.catalina.startup.HostConfig deployDirectory
严重: Error deploying web application directory G:\MYeclipse\.metadata\.me_tcat85\webapps\zdfg
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/zdfg]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:756)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1107)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1841)
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:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
-----------------------------------------------------------------------------------------------------------------------
粗略看显示的错误信息,发现出错的不是自己写的相关类。
于是复制“org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext”进行百度,得出如下可能发生的错误信息:
1.web.xml里的信息没配置好。例如<url-pattern><url-pattern/>中少写<url-pattern>/<url-pattern/>,那个左斜杠没有写导致报错。这个是web.xml报错最多的原因。其他还有标签不匹配或者是写错标签。于是后面我对我项目中的web.xml进行反复查错,甚至把web.xml的版本号都改了几个版本,结果启动tomcat依旧报错。这时想到会不会我是myeclipse自带的tomcat本身有问题呢,于是新建一个空的web项目启动,tomcat正常运行。。。
2.自己写的controller包中的类有报错或者是类中的映射路径有问题。接着又是一顿反复查错,项目本身不报错,又进到每个类中查看业务逻辑代码是否存在问题。得出结论:无肉眼或者现阶段能够发现的错误。。
3.需要修改tomcat的配置文件的一行配置。但是我用是myeclipse自带的tomcat8.5版本,根本找不到所说的那个properties文件,于是放弃。
4.(睡一觉后的思路)我新建一个空的web项目,tomcat启动没问题。将所有的自己写的包和类复制进去,启动没问题(此时因为没有导入jar包,所以许多类是报错的) 。到这我就有种想法,会不会是本身jar包有问题?于是我先讲spring和mybatis的jar包导进去,启动也没问题,后面就一个jar包一个jar包的导进去,最后发现当导入log4j-1.2.17的jar包,项目报出上面所示错误!出于严谨,我将除log4j-1.2.17的jar包之外的其他剩余jar包都导进去,项目启动没问题。接着我到http://mvnrepository.com/重新下载一个log4j-1.2.17的jar包导进去,项目也没问题!!!最终得出,原log4j-1.2.17的jar包导致的上诉异常!
总结:有上诉异常的,若百度了的解决方法都尝试了但是还是找不到异常出自哪里,那么可以检查下jar包是否出现问题了。。