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.
pom.xml
to see if there's anything else that may be related to this problem? Also, have you triedmvn dependency:tree
to see if any other dependency pulls inapache-commons
? Just want to eliminate some of the more straightforward possibilities. – Justin Albano