I am creating building a jar which will also include its dependencies. I am using maven shade plugin for this. But getting Caused by: java.util.zip.ZipException: invalid LOC header
error while building. I tried excluding the transitive dependency as shown below still getting error.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tlt.idk</groupId>
<artifactId>saba-user-import</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>CSVSabaUserImport</name>
<dependencies>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>3.3</version>
<exclusions>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons.lang3</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<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>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>ImportCsv</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Caused by: java.io.IOException: Problem shading JAR C:\Users\Admin.m2\repository\org\apache\commons\commons-lang3\3.3.2\commons-lang3-3.3.2.jar entry META-INF/LICENSE.txt: java.util.zip.ZipException: invalid LOC header (bad signature) at org.apache.maven.plugins.shade.DefaultShader.shadeJars(DefaultShader.java:197) at org.apache.maven.plugins.shade.DefaultShader.shade(DefaultShader.java:106) at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:442) ... 21 more Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
Any help in this regard will be appreciated.
I guess there was an error downloading the dependency. This happend quite often when eclipse downloaded the dependencies for me.
Delete the corrupted artifact from your maven cache (located in C:\Users\<username>\.m2\respository
).