Maven整合struts2框架运行时org.apache.catalina.core.ContainerBase addChildInternal :ContainerBase.addChild

Tomcat运行时报错展示:

九月 30, 2019 7:26:54 下午 org.apache.catalina.core.ContainerBase addChildInternal
严重: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[172.20.185.146].StandardContext[/st9_1]]
	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:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@768740cd]
	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@1847508d]
	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:734)
	at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:434)
	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
九月 30, 2019 7:26:54 下午 org.apache.catalina.startup.HostConfig deployDirectory
严重: Error deploying web application directory D:\MyEclilpse\caozuo\.metadata\.me_tcat85\webapps\st9_1
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[172.20.185.146].StandardContext[/st9_1]]
	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:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

报错原因:我的JDK版本是1.8,我的pom.xml中引用的strut2的版本是2.3.24
Maven整合struts2框架运行时org.apache.catalina.core.ContainerBase addChildInternal :ContainerBase.addChild_第1张图片
依赖的包:
Maven整合struts2框架运行时org.apache.catalina.core.ContainerBase addChildInternal :ContainerBase.addChild_第2张图片
struts2里面依赖xwork-core,而xwork-core依赖asm-*。网上查了一下才知道,低版本的ASM不能在JDK1.8环境中使用。

这里我选择了用struts2的版本在2.5以上的方法。这个版本将xwork依赖直接合并到struts2-core中了。而且使用了asm 5.X版本,支持JDK1.8。

更改之后的pod.xml。
Maven整合struts2框架运行时org.apache.catalina.core.ContainerBase addChildInternal :ContainerBase.addChild_第3张图片
依赖的包:
Maven整合struts2框架运行时org.apache.catalina.core.ContainerBase addChildInternal :ContainerBase.addChild_第4张图片
然后在web.xml中的配置。

 
   struts2
   org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
 
 
   struts2
   /*
 

之前的核心过滤器全类名会有个ng ,struts2.5核心过滤器没有这个。

然后运行没问题。
Maven整合struts2框架运行时org.apache.catalina.core.ContainerBase addChildInternal :ContainerBase.addChild_第5张图片

你可能感兴趣的:(bug处理,maven,struts2,jdk,tomcat)