tomcat启动报错 java.util.zip.ZipException: invalid CEN header (bad signature)

简介: war包部署到tomcat里,启动时报错: Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.

war包部署到tomcat里,启动时报错:

Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet@7e21e65f]
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:136)
    at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:699)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    ... 14 more
Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: invalid CEN header (bad signature)
    at org.apache.catalina.webresources.JarResourceSet.initInternal(JarResourceSet.java:139)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
    ... 17 more
Caused by: java.util.zip.ZipException: invalid CEN header (bad signature)
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:214)
    at java.util.zip.ZipFile.<init>(ZipFile.java:144)
    at java.util.jar.JarFile.<init>(JarFile.java:152)
    at java.util.jar.JarFile.<init>(JarFile.java:89)
    at org.apache.catalina.webresources.JarResourceSet.initInternal(JarResourceSet.java:136)
    ... 18 more

根据ZipException报错,怀疑是jar包有损坏。

为了定位是哪个jar包,使用下面shell脚本,用jar命令测试jar包:

cd WEB-INF/lib/
for j in *.jar; do echo $j; jar tvf $j > /dev/null ; echo $j done; done

正常的jar包只打印出jar的文件名,损坏的jar包会打印出错误信息

aspectjweaver-1.6.9.jar
java.util.zip.ZipException: invalid CEN header (bad signature)
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:225)
        at java.util.zip.ZipFile.<init>(ZipFile.java:155)
        at java.util.zip.ZipFile.<init>(ZipFile.java:126)
        at sun.tools.jar.Main.list(Main.java:1115)
        at sun.tools.jar.Main.run(Main.java:293)
        at sun.tools.jar.Main.main(Main.java:1288)

从maven仓库中删除这个jar,重新maven打包。

另外,遇到 invalid LOC header (bad signature) 错误,
用jar tvf命令就检查不出来了。可以使用unzip -t命令检测。

for j in *.jar; do echo $j; unzip -t $j > /dev/null ; if [ $? -ne 0 ]; then echo $j error; fi; echo $j done; done


mysql-connector-java-5.1.27.jar
warning [mysql-connector-java-5.1.27.jar]:  317386 extra bytes at beginning or within zipfile
  (attempting to process anyway)
file #1:  bad zipfile offset (local header sig):  317386
  (attempting to re-compensate)
mysql-connector-java-5.1.27.jar error
目录
相关文章
|
3天前
|
存储 Java Linux
Java“Bad Magic Number”错误解决
Java“Bad Magic Number”错误通常发生在尝试运行不兼容或损坏的类文件时。解决方法包括确保使用正确的JDK版本、检查类文件完整性、清理和重新编译项目。
|
6月前
|
Java 应用服务中间件 Spring
SpringBoot出现 java.lang.IllegalArgumentException: Request header is too large 解决方法
SpringBoot出现 java.lang.IllegalArgumentException: Request header is too large 解决方法
229 0
|
4月前
|
消息中间件 Java Maven
java.util.zip.ZipException: invalid LOC header (bad signature)
java.util.zip.ZipException: invalid LOC header (bad signature)
53 1
|
6月前
|
Java 应用服务中间件 Shell
Tomcat 安装配置教程及成功后,启动失败报错解决方案
Tomcat 安装配置教程及成功后,启动失败报错解决方案
114 0
|
6月前
|
前端开发 Java 应用服务中间件
springboot 升级(1.5.7.RELEASE升级到2.7.10) Tomcat启动报错
springboot 升级(1.5.7.RELEASE升级到2.7.10) Tomcat启动报错
|
6月前
|
Java 应用服务中间件
解决tomcat启动报错:无法在web.xml或使用此应用程序部署的jar文件中解析绝对的url [http:java.sun.com/jsp/jstl/core]
解决tomcat启动报错:无法在web.xml或使用此应用程序部署的jar文件中解析绝对的url [http:java.sun.com/jsp/jstl/core]
1292 1
|
6月前
|
SQL Java 数据库连接
解决bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符
解决bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符
127 0
|
6月前
java.lang.IllegalArgumentException: Invalid character found in method name
java.lang.IllegalArgumentException: Invalid character found in method name
178 0
|
6月前
|
SQL Java 数据库连接
解决bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符
解决bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符
100 0
|
Java 索引 分布式计算