报错:Invalid signature file digest for Manifest main attributes
项目在本机上正常运行,但是部署到服务器的tomcat上就是启动不了,报如下错误:
Caused by: java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:239) [:1.6.0_30]
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:193) [:1.6.0_30]
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:296) [:1.6.0_30]
at java.util.jar.JarVerifier.update(JarVerifier.java:207) [:1.6.0_30]
at java.util.jar.JarFile.initializeVerifier(JarFile.java:342) [:1.6.0_30]
at java.util.jar.JarFile.getInputStream(JarFile.java:410) [:1.6.0_30]
at org.jboss.vfs.spi.JavaZipFileSystem.getFile(JavaZipFileSystem.java:159) [jboss-vfs.jar:3.0.0.GA]
at org.jboss.vfs.VirtualFile.getPhysicalFile(VirtualFile.java:262) [jboss-vfs.jar:3.0.0.GA]
at org.jboss.web.deployers.AbstractWarDeployer$1.visit(AbstractWarDeployer.java:853) [:6.0.0.Final]
at org.jboss.vfs.VirtualFile.visit(VirtualFile.java:408) [jboss-vfs.jar:3.0.0.GA]
at org.jboss.vfs.VirtualFile.visit(VirtualFile.java:410) [jboss-vfs.jar:3.0.0.GA]
at org.jboss.vfs.VirtualFile.visit(VirtualFile.java:410) [jboss-vfs.jar:3.0.0.GA]
at org.jboss.vfs.VirtualFile.visit(VirtualFile.java:410) [jboss-vfs.jar:3.0.0.GA]
at org.jboss.vfs.VirtualFile.visit(VirtualFile.java:396) [jboss-vfs.jar:3.0.0.GA]
at org.jboss.web.deployers.AbstractWarDeployer.getExplodedWarUrl(AbstractWarDeployer.java:866) [:6.0.0.Final]
at org.jboss.web.deployers.AbstractWarDeployer.deploy(AbstractWarDeployer.java:400) [:6.0.0.Final]
... 47 more
一番上网查询几乎都是问题出在 META-INF 文件夹中,打包的 jar 或 war 的 META-INF 文件夹中有文件,jboss 正在尝试处理这些文件或不希望在那里处理这些文件。
但是发现自己打包的 META-INF 文件夹下空空如也, 并没有*.RSA ,*.DSA ,*.SF等文件,百思不得其解。
也尝试过重新打包、更换tomcat版本等途径,并没有解决此问题。
最后想到项目是分模块的,是不是引用的子模块产生的jar包内有这些文件,最终一个一个检查过去,终于找到了问题所在:
有一个子模块的jar存在这些*.RSA ,*.DSA ,*.SF文件
将这个jar包去除这些文件:
zip -d <jar file name>.jar META-INF/*.RSA META-INF/*.DSA META-INF/*.SF
但这治标不治本,下次打包依旧会有此问题,最终去pom.xml文件里排除META-INF/*.SF等文件
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<!-- 排除以下文件,防止程序启动启动时,校验错误 -->
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
参考:
https://www.it610.com/article/1297150525044760576.htm
https://blog.csdn.net/zifanyou/article/details/85069819