Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
320 views
in Technique[技术] by (71.8m points)

java - Error while creating consolidated jar file - no manifiest section for signature file entry javax/mail/internet/ContentDisposition.class

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

I am using 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 run the jar using "java -jar mytest.jar" command, it says:

Exception in thread "main" java.lang.SecurityException: no manifiest section for signature file entry javax/mail/internet/ContentDisposition.class at sun.security.util.SignatureFileVerifier.verifySection(Unknown Source) at sun.security.util.SignatureFileVerifier.processImpl(Unknown Source)

Any idea, how to make a consolidated jar that have no such issues, would be highly appreciated. I am using IntelliJ IDEA.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Exception in thread "main" java.lang.SecurityException: no manifiest section for signature file entry

This error message tells exactly why bundled jar is not recommended for production release. The problem is some of your dependency jar is signed with signature files. repack it may violate some security policy on the dependency jar.

To make it work, you need remove all signature files from the signed jar, before copying the unpacked files into your final build jar file. Note that <zipgroupfileset> doesn't support exclude file within jar archive, try using a list of <zipfileset> instead:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...