An error occurred while creating a consolidated jar file - there is no explicit section for writing a javax / mail / internet / ContentDisposition.class signature file

I have some jar files in / libs / and my project classes are located in / target /. To remove the dependency on an external folder. I want to create a consolidated jar file. Which contains all the classes from the jar files found in all / libs / *. Jar

I am using the following Ant script:

<jar destfile="mytest.jar" basedir="target/classes"> <manifest> <attribute name="Main-Class" value="com.mytest.MyProcessor"/> </manifest> <fileset dir="target/classes" includes="**/*.class"/> <zipgroupfileset dir="libs" includes="*.jar"/> </jar> 

But when I start the jar using the command "java -jar mytest.jar", it says:

An exception in the "main" thread java.lang.SecurityException: there is no explicit section for writing the javax / mail / internet / ContentDisposition.class signature file at sun.security.util.SignatureFileVerifier.verifySection (Unknown source) at sun.security.util.SignatureFileVerifier .processImpl (Unknown source)

Any idea how to make a consolidated bank that does not have such problems will be highly appreciated. I am using IntelliJ IDEA.

+4
source share
4 answers

Exception in thread "main" java.lang.SecurityException: there is no explicit section for writing a signature file

This error message accurately indicates why the pack gang is not recommended for product release. The problem is that some of your dependency banners are signed with signature files. repack it may violate some security policy in the dependency bank.

To make it work, you need to delete all the signature files from the signed jar before copying the unpacked files to your final jar build file. Please note that <zipgroupfileset> does not support file exclusion in the jar archive, try using the <zipfileset> list instead:

 <zipfileset src="libs/mail.jar"> <exclude name="**/*.RSA, **/*.SF, **/*.DSA"/> </zipfileset> ... ... 
+9
source

Something like this might work for you.

 <jar destfile="mytest.jar" basedir="target/classes"> <restrict> <not> <or> <name name="**/*.RSA"/> <name name="**/*.SF"/> <name name="**/*.DSA"/> </or> </not> <archives> <zips> <fileset dir="libs" includes="**/*.jar"/> </zips> </archives> </restrict> <manifest> <attribute name="Main-Class" value="com.mytest.MyProcessor"/> </manifest> </jar> 

I adapted this from an example in http://ant.apache.org/manual/Tasks/jar.html in the section "Combining archives".

+2
source

Use Maven and a tint plugin. Take a look at http://maven.apache.org/plugins/maven-shade-plugin/

+1
source

I would suggest untying all your jar files into a lib folder, and then jar along with your source code, try this might work for you.

0
source

Source: https://habr.com/ru/post/1400103/


All Articles