1. 程式人生 > >Tomcat報org.apache.catalina.LifecycleException: Failed to start component [StandardEngine...

Tomcat報org.apache.catalina.LifecycleException: Failed to start component [StandardEngine...

具體錯誤如下:

嚴重: ContainerBase.addChild: start:   
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/test]]  
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)  
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)  
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)  
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)  
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:587)  
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1798)  
    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 [
[email protected]
] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162) at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4969) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5099) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) ... 10 more Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [
[email protected]
] at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:135) at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:706) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) ... 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:102) ... 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

可能的原因:

1、如果是maven專案的話,可能是由於一些未知原因導致jar沒下來來,因此我們可以

(1)清空本地maven倉庫

(2)執行maven update重新下載jar包

2、可能由於web.xml的驗證中

<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

版本和約束跟tomcat對應的servlet api的版本不匹配。

解決辦法:

專案-->properties-->project facets:

選擇對應的Dynamic web module的版本。

修改時如果出現Cannot change version of project facet Dynamic Web Module to xx。xx為要修改成為的版本,如:3.0。

解決辦法:

找到工作空間中的專案,開啟專案找到.settings資料夾開啟,編輯兩個檔案:

1.org.eclipse.jdt.core.prefs.prefs檔案中的:

eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8

將1.8修改成對應的jdk版本

2.org.eclipse.wst.common.project.facet.core.xml檔案中:

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="Apache Tomcat v8.5"/>
<fixed facet="wst.jsdt.web"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="java" version="1.8"/>
<installed facet="jst.web" version="3.0"/>
</faceted-project>

將這個<installed facet="java" version="1.8"/>改成對應的java版本號,<installed facet="jst.web" version="3.1"/>改成對應的Dynamic Web module的版本號。

然後再開啟project facet 檢視是否修改。