invalid LOC header (bad signature)

今天,在调试运行SSM代码的时候,遇到了问题。出错的错误信息如下:

org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/myProject]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:596)
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1805)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@95e0743]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)
    at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4850)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4982)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
    ... 10 more
Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet@6a44e649]
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:111)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:141)
    at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:701)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
    ... 13 more
Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: invalid LOC header (bad signature)
    at org.apache.catalina.webresources.JarResourceSet.initInternal(JarResourceSet.java:139)
    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(Unknown Source)
    at java.util.zip.ZipFile$ZipFileInputStream.read(Unknown Source)
    at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(Unknown Source)
    at java.util.zip.InflaterInputStream.read(Unknown Source)
    at sun.misc.IOUtils.readFully(Unknown Source)
    at java.util.jar.JarFile.getBytes(Unknown Source)

eclipse部署到tomcat中进行运行,但是报错的同时,在指定的tomcat文件内找不到部署的项目文件。最终,在Stack Overflow找到了解答。但是,一直不懂,为什么需要把jar包删除,然后再重新更新即可解决此类问题。如是查找了相关的日志,在(/workspace/.metadata/.log)找到以下信息:

org.eclipse.jst.jee.archive.ArchiveOpenFailureException: C:\Users\liu.jiang\.m2\repository\org\springframework\spring-webmvc\4.3.10.RELEASE\spring-webmvc-4.3.10.RELEASE.jar
    at org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentLoadAdapter.<init>(JavaEEBinaryComponentLoadAdapter.java:56)
    at org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities.openBinaryArchive(JavaEEArchiveUtilities.java:250)
    at org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper$ArchiveCache.openArchive(JavaEEBinaryComponentHelper.java:612)
    at org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper.openArchive(JavaEEBinaryComponentHelper.java:470)
    at org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper.getUniqueArchive(JavaEEBinaryComponentHelper.java:422)
    at org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper.getArchive(JavaEEBinaryComponentHelper.java:415)
    at org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper.getJavaEEQuickPeek(JavaEEBinaryComponentHelper.java:98)
    at org.eclipse.jst.j2ee.project.JavaEEProjectUtilities.getJ2EEComponentType(JavaEEProjectUtilities.java:273)
    at org.eclipse.jst.j2ee.internal.common.exportmodel.JEEHeirarchyExportParticipant.isChildModule(JEEHeirarchyExportParticipant.java:42)
    at org.eclipse.wst.common.componentcore.internal.flat.GlobalHeirarchyParticipant.isChildModule(GlobalHeirarchyParticipant.java:41)
    at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.isChildModule(FlatVirtualComponent.java:367)
    at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.addUsedReferences(FlatVirtualComponent.java:305)
    at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.treeWalk(FlatVirtualComponent.java:235)
    at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.cacheResources(FlatVirtualComponent.java:188)
    at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.getChildModules(FlatVirtualComponent.java:160)
    at org.eclipse.wst.web.internal.deployables.FlatComponentDeployable.getExportModelChildren(FlatComponentDeployable.java:252)
    at org.eclipse.wst.web.internal.deployables.FlatComponentDeployable.getModules(FlatComponentDeployable.java:263)
    at org.eclipse.jst.server.tomcat.core.internal.TomcatServer.getChildModules(TomcatServer.java:386)
    at org.eclipse.wst.server.core.internal.Server.getChildModules(Server.java:2637)
    at org.eclipse.wst.server.core.internal.Server.visitModule(Server.java:3058)
    at org.eclipse.wst.server.core.internal.Server.visit(Server.java:3039)
    at org.eclipse.wst.server.core.internal.Server.getAllModules(Server.java:1542)
    at org.eclipse.wst.server.ui.internal.cnf.ServersView2$3.run(ServersView2.java:189)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.io.FileNotFoundException: C:\Users\liu.jiang\.m2\repository\org\springframework\spring-webmvc\4.3.10.RELEASE\spring-webmvc-4.3.10.RELEASE.jar (系统找不到指定的路径。)
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(Unknown Source)
    at java.util.zip.ZipFile.<init>(Unknown Source)
    at org.eclipse.jst.common.internal.modulecore.util.ManifestUtilities$1.<init>(ManifestUtilities.java:259)
    at org.eclipse.jst.common.internal.modulecore.util.ManifestUtilities.newZipFile(ManifestUtilities.java:259)
    at org.eclipse.jst.jee.archive.internal.ArchiveUtil.newZipFile(ArchiveUtil.java:248)
    at org.eclipse.jst.jee.archive.internal.ArchiveUtil.newZipFile(ArchiveUtil.java:234)
    at org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentLoadAdapter.resetZipFile(JavaEEBinaryComponentLoadAdapter.java:67)
    at org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentLoadAdapter.<init>(JavaEEBinaryComponentLoadAdapter.java:51)
    ... 23 more

根据日志的展示,说明jar包在读取的时候,并没有找到任何的jar包信息。到现在依然不是很懂,为什么删除再更新,他就会读取到。之前也遇到过类似的问题,那时候是吧项目删除,新建了一个项目就解决问题了。不知道是eclipse的问题,还是maven的问题,还是其他的问题。

总结:
* 删掉.m2/repository 文件夹内的所有内容,然后maven install
* 或者尝试我之前,把项目删掉,新建一个项目,然后把代码复制进去。(推荐第一种,因为Stack Overflow 上好像很多人遇到了这样的问题,然后重新更新了jar包就好了。毕竟走人多的路,陷阱少,适合的人多)

参考地址:https://stackoverflow.com/questions/32090921/maven-invalid-loc-header-bad-signature

发表评论

This site uses Akismet to reduce spam. Learn how your comment data is processed.