I added a Jar file to the build path in an Eclipse project, but the situation and what to do when `java.util.zip.ZipException: invalid LOC header (bad signature)` appears.

tl;dr

Mostly because the downloaded Jar seems to be broken, so it can not be expanded. It's best to download it again.

Occurrence timing and countermeasures

Normal Java project

--Occurrence timing --Should happen after adding the Jar file to the build path --Corrective action --Re-download the Jar added to the build path and re-install it

Maven project

--Occurrence timing --<dependency> Should happen after adding and downloading --Corrective action --For Windows, go to % USERPROFILE% \ .m2 and delete the repository directory --For Linux etc., is it $ HOME / .m2?

Phenomenon (example)

Example: Eclipse gives an error when saving code

Below, from the "Error Log" view of Eclipse.

image.png

Example: JDT cannot start tomcat

Below, from the "Console" view of Eclipse.

Serious: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet@16aa0a0a]
	at java.util.concurrent.FutureTask.report(Unknown Source)
	at java.util.concurrent.FutureTask.get(Unknown Source)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:949)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1427)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1417)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:258)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:682)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet@16aa0a0a]
	at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:441)
	at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:139)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:173)
	at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:724)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4742)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4877)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1427)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1417)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943)
	... 21 more
Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: invalid LOC header (bad signature)
	at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:143)
	at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
	... 33 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)
	at java.util.jar.JarFile.getManifestFromReference(Unknown Source)
	at java.util.jar.JarFile.getManifest(Unknown Source)
	at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:141)
	... 34 more

complaints

I wonder if there is a device that just recalculates and sends without checking the checksum.

Recommended Posts

I added a Jar file to the build path in an Eclipse project, but the situation and what to do when `java.util.zip.ZipException: invalid LOC header (bad signature)` appears.
[Rails] What to do when the error No database selected and Unknown database appears in db: migrate
What to do if you get a JNI shared library error when trying to build in Eclipse
What to do when an UnsupportedCharsetException occurs in a lightweight JRE
What to do and how to install when an error occurs in DXRuby 1.4.7
What to do if you are told "there is no main manifest attribute" when creating a jar file containing dependencies in a maven project
What I did when I was addicted to the error "Could not find XXX in any of the sources" when I added a Gem and built it
What to do if you get Could not save master table to file after importing a project in Eclipse
What to do if Command line is too long appears when building a gradle project in Intellij IDEA
Introducing what I made when I wanted to add a header and footer to RecyclerView
What to do when "Fail to load the JNI shared library" is displayed in Eclipse
What to do when an error (StandardError: An error has occurred, this and all later migrations canceled:) appears in rails db: migrate
What to do if you select a JRE in Eclipse and get "The selected JRE does not support the current compliance level 11"
What to do when rails creates a 〇〇 2.rb file
How to debug the generated jar file in Eclipse
When I switched to IntelliJ, I got a lot of differences in the encoding of the properties file.
What to do when a could not find driver appears when connecting to a DB in a Docker environment
[Rails Tutorial Chapter 2] What to do when you make a mistake in the column name
What you need to do to open a file from the menu in the document-Based App macOS app