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

前端 未结 4 1230
长情又很酷
长情又很酷 2020-12-18 09:48

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 conta

相关标签:
4条回答
  • 2020-12-18 10:13

    I would suggest to unjar all your jar files into a lib folder and then jar together with your your source code, try it might work for you.

    0 讨论(0)
  • 2020-12-18 10:21

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

    0 讨论(0)
  • 2020-12-18 10:23

    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 the example at http://ant.apache.org/manual/Tasks/jar.html under the "Merging archives" section.

    0 讨论(0)
  • 2020-12-18 10:35

    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>
    ... ...
    
    0 讨论(0)
提交回复
热议问题