无法部署war文件:打开zip文件时出错

d6kp6zgx  于 2021-08-20  发布在  Java
关注(0)|答案(4)|浏览(451)

我正在开发一个基于java的web应用程序,该应用程序使用jetty在本地正确运行,但我无法使用tomcat在linux服务器上部署war版本。我进入catalina.out文件:打开zip文件时出错。
我读了很多关于这个错误的主题(权限,损坏的jar文件…),但是没有一个对我有帮助。如何找到有关此错误的更多解释或详细信息?
以下是堆栈跟踪:

18-Jan-2016 10:39:01.036 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1663 ms
18-Jan-2016 10:39:01.109 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
18-Jan-2016 10:39:01.109 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.30
18-Jan-2016 10:39:01.168 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /opt/tomcat/webapps/UserInterface-1.0-SNAPSHOT.war
18-Jan-2016 10:39:02.235 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: 
 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/UserInterface-1.0-SNAPSHOT]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    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.deployWAR(HostConfig.java:945)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1795)
    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@6da9455d]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4928)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5058)
    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@6e366f32]
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
    at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:699)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 13 more
Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: error in opening zip file
    at org.apache.catalina.webresources.JarResourceSet.initInternal(JarResourceSet.java:96)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
    ... 16 more
Caused by: java.util.zip.ZipException: error in opening zip file
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:219)
    at java.util.zip.ZipFile.<init>(ZipFile.java:149)
    at java.util.jar.JarFile.<init>(JarFile.java:166)
    at java.util.jar.JarFile.<init>(JarFile.java:103)
    at org.apache.catalina.webresources.JarResourceSet.initInternal(JarResourceSet.java:88)
    ... 17 more

谢谢

66bbxpm5

66bbxpm51#

造成这一问题的可能原因是:
1.您的应用程序/web inf/lib可能包含重复的jar
2.对应用程序或应用程序/web inf/lib的权限不正确

kmb7vmvb

kmb7vmvb2#

我遇到了类似的问题。”原因:java.util.zip.zipexception:打开zip文件时出错”,我删除了.m2/repository文件夹,重新生成war,然后修复。

kmynzznz

kmynzznz3#

此问题主要是因为部署war文件中的JAR已损坏。

unzip <artifact-name>.war 
find <artifact-folder>  -name "*jar" | xargs -L 1 zip -T | grep error | grep invalid

这将列出控制台中损坏的jar。
一旦发现损坏的JAR,可以手动替换lib文件夹中的JAR,也可以创建新的构建并部署它。

laximzn5

laximzn54#

我也遇到了同样的问题,因为jar损坏了。
解决方案:删除损坏的jar并从正确的jar中再次替换它。创建新的war文件

相关问题