创建合并的 jar 文件时出错 - 没有签名文件条目 javax/mail/internet/ContentDisposition.class 的清单部分 [英] Error while creating consolidated jar file - no manifiest section for signature file entry javax/mail/internet/ContentDisposition.class

查看:33
本文介绍了创建合并的 jar 文件时出错 - 没有签名文件条目 javax/mail/internet/ContentDisposition.class 的清单部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在/libs/中有一些 jar 文件,我的项目类位于/target/.删除对外部文件夹的依赖.我想制作一个整合的 jar 文件.其中包含所有/libs/*.jar

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

我正在使用以下 Ant 脚本:

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>

但是,当我使用java -jar mytest.jar"命令运行 jar 时,它说:

线程main"中的异常 java.lang.SecurityException:没有签名文件条目 javax/mail/internet/ContentDisposition.class 的清单部分在 sun.security.util.SignatureFileVerifier.verifySection(来源不明)在 sun.security.util.SignatureFileVerifier.processImpl(来源不明)

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)

任何想法,如何制作没有此类问题的合并罐,将不胜感激.我正在使用 IntelliJ IDEA.

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

推荐答案

线程main"中的异常java.lang.SecurityException:没有签名文件条目的清单部分

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

此错误消息准确地说明了为什么不建议将捆绑的 jar 用于生产版本.问题是你的一些依赖 jar 是用签名文件签名的.重新打包它可能会违反依赖 jar 的某些安全策略.

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.

要使其工作,您需要从已签名的 jar 中删除所有签名文件,然后再将解压缩的文件复制到您的最终构建 jar 文件中.请注意,<zipgroupfileset>不支持排除 jar 档案中的文件,请尝试使用 <zipfileset> 列表.相反:

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>
... ...

这篇关于创建合并的 jar 文件时出错 - 没有签名文件条目 javax/mail/internet/ContentDisposition.class 的清单部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆