0

I use Tomcat 8 and such Jersey's dependencies for Dynamic Web Project.

<dependencies>
    <!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-client -->
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
        <version>1.17.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-server -->
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-server</artifactId>
        <version>1.17.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-core -->
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-core</artifactId>
        <version>1.17.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-servlet -->
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-servlet</artifactId>
        <version>1.17.1</version>
    </dependency>
</dependencies>

When running I receive error caused by:

Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: invalid LOC header (bad signature)
at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:113)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
... 12 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:111)
... 13 more

I can't find out what I do wrong. Is it problem in compatibility of such Jersey's dependencies and Tomcat version? If you need I can add some information about project overall.

Valeriy Fedosov
  • 65
  • 3
  • 12
  • Best guess: A corrupt jar file. Too bad the error message doesn't include the name of the offending file. I'd suggesting trying to debug Tomcat, and put a breakpoint on the `ZipException`, so you might be able to find the file causing your issue. – Andreas Apr 11 '17 at 17:02
  • It seems very difficult) Maybe someone can share the working versions of Jersey? – Valeriy Fedosov Apr 11 '17 at 17:15
  • The files are on the [Maven repository](https://mvnrepository.com/artifact/com.sun.jersey). Go download them manually, then compare to what you have. – Andreas Apr 11 '17 at 17:17
  • check if in lib some non-jar file is present ,i used to have issue due to it – gladiator Apr 13 '17 at 08:47

2 Answers2

0

Here my maven's dependencies: enter image description here

They're all jars)

Community
  • 1
  • 1
Valeriy Fedosov
  • 65
  • 3
  • 12
0

I haven't been able to reproduce your error; I used your dependencies and my jersey app works fine. It's definitely a corrupt jar, as indicated by multiple other questions: tomcat server fails to start the server and application in STS, Server does not starts with spring app, Tomcat Server failing to start. It sometimes happens when there's a problem with the internet connection while the jars were being downloaded.

  1. Delete all jars in the maven repository folder, by default located at Users/{yourusername}/.m2/repository.

  2. Right click on your project, choose Maven -> Update Project -> check Force Update of Snapshots/Releases -> Ok.

All the jar files get downloaded again from the Maven repository. It should work fine.

Community
  • 1
  • 1
Ray
  • 3,864
  • 7
  • 24
  • 36