java.lang.SecurityException:没有签名文件条目的清单部分

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20045744/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 22:39:10  来源:igfitidea点击:

java.lang.SecurityException: no manifest section for signature file entry

javasecurityant

提问by Volodymyr Levytskyi

I have tried suggestions in other threads but they don't help me. When I run my jar by java -jar -BigJar.jarI receive exception :

我已经尝试过其他线程中的建议,但它们对我没有帮助。当我运行 jar 时java -jar -BigJar.jar收到异常:

Exception in thread main java.lang.SecurityException: no manifest section for signature fil entry edu/iris/Pissures/IfSeismogramMgr/MotionVectorAttributeHelper.class

Exception in thread main java.lang.SecurityException: no manifest section for signature fil entry edu/iris/Pissures/IfSeismogramMgr/MotionVectorAttributeHelper.class

My ant file is

我的蚂蚁档案是

<project name="USGS VHP" default="help" basedir=".">
    <description>USGS VHP Main Build File</description>

    <property name="root" location="." />
    <property name="classdir" value="classes" />
    <property name="contrib" value="http://volcanoes.usgs.gov/software/contrib" />


    <target name="help">
        <echo>
Available targets:          
help    -- displays this help information
init    --
clean   -- deletes lib/*.jar files
touch   -- touch *.java in source tree
contrib -- download the contrib library (use before building)
build   -- build the USGS codebase (use after checkout *)
        </echo>
    </target>

    <target name="init">
    </target>



    <target name="clean">
        <delete>
            <fileset dir="${root}/lib/" includes="*.jar" />
        </delete>
    </target>

    <target name="touch">
        <touch>
            <fileset dir="${root}/../" includes="**/*.java" />
        </touch>
    </target>



    <target name="contrib" depends="init" description="Download the contrib libraries">
        <mkdir dir="${root}/contrib" />
        <get src="${contrib}/colt.jar" dest="${root}/contrib/colt.jar" />
        <get src="${contrib}/comm.jar" dest="${root}/contrib/comm.jar" />
        <get src="${contrib}/commons-collections-3.2.1.jar" dest="${root}/contrib/commons-collections-3.2.1.jar" />
        <get src="${contrib}/fissuresIDL-1.0.jar" dest="${root}/contrib/fissuresIDL-1.0.jar" />
        <get src="${contrib}/fissuresImpl-1.1.13.jar" dest="${root}/contrib/fissuresImpl-1.1.13.jar" />
        <get src="${contrib}/fissuresUtil-1.0.18.jar" dest="${root}/contrib/fissuresUtil-1.0.18.jar" />
        <get src="${contrib}/forms-1.0.7.jar" dest="${root}/contrib/forms-1.0.7.jar" />
        <get src="${contrib}/jai_codec.jar" dest="${root}/contrib/jai_codec.jar" />
        <get src="${contrib}/jai_core.jar" dest="${root}/contrib/jai_core.jar" />
        <get src="${contrib}/jnlp.jar" dest="${root}/contrib/jnlp.jar" />
        <get src="${contrib}/JSAP-2.1.jar" dest="${root}/contrib/JSAP-2.1.jar" />
        <get src="${contrib}/jtransforms-2.4.jar" dest="${root}/contrib/jtransforms-2.4.jar" />
        <get src="${contrib}/log4j-1.2.13.jar" dest="${root}/contrib/log4j-1.2.13.jar" />
        <get src="${contrib}/looks-2.0.4.jar" dest="${root}/contrib/looks-2.0.4.jar" />
        <get src="${contrib}/mysql.jar" dest="${root}/contrib/mysql.jar" />
        <get src="${contrib}/rrd4j-2.0.5.jar" dest="${root}/contrib/rrd4j-2.0.5.jar" />
        <get src="${contrib}/JavaSeedLite.jar" dest="${root}/contrib/JavaSeedLite.jar" />
        <get src="${contrib}/seedCodec-1.0.6.jar" dest="${root}/contrib/seedCodec-1.0.6.jar" />
        <get src="${contrib}/servlet.jar" dest="${root}/contrib/servlet.jar" />
        <get src="${contrib}/seisFile-1.5.2.jar" dest="${root}/contrib/seisFile-1.5.2.jar" />
        <get src="${contrib}/slf4j-api-1.7.1.jar" dest="${root}/contrib/slf4j-api-1.7.1.jar" />
        <get src="${contrib}/slf4j-log4j12-1.7.1.jar" dest="${root}/contrib/slf4j-log4j12-1.7.1.jar" />
        <get src="${contrib}/javassist.jar" dest="${root}/contrib/javassist.jar" />
        <get src="${contrib}/thymeleaf-2.0.13.jar" dest="${root}/contrib/thymeleaf-2.0.13.jar" />
        <get src="${contrib}/ognl-2.6.7.jar" dest="${root}/contrib/ognl-2.6.7.jar" />
        <get src="${contrib}/oscache-2.1-mod2.jar" dest="${root}/contrib/oscache-2.1-mod2.jar" />
        <get src="${contrib}/seedlink_lite_1.2.1.jar" dest="${root}/contrib/" />
        <get src="${contrib}/seedlink_lite_src_1.2.1.jar" dest="${root}/contrib/" />
        <get src="http://repo1.maven.org/maven2/com/h2database/h2/1.3.173/h2-1.3.173.jar" dest="${root}/contrib/h2.jar" />
    </target>



    <target name="build" depends="init" description="Build USGS codebase">
        <!-- Order is important.  Some projects depend on others. -->
        <ant target="jar" inheritAll="false" antfile="${root}/../Util/build.xml" />
        <ant target="jar" inheritAll="false" antfile="${root}/../Math/build.xml" />
        <ant target="jar" inheritAll="false" antfile="${root}/../Net/build.xml" />
        <ant target="jar" inheritAll="false" antfile="${root}/../Plot/build.xml" />
        <ant target="jar" inheritAll="false" antfile="${root}/../Pinnacle/build.xml" />
        <ant target="jar" inheritAll="false" antfile="${root}/../VDX/build.xml" />
        <ant target="jar" inheritAll="false" antfile="${root}/../Valve3/build.xml" />
        <ant target="jar" inheritAll="false" antfile="${root}/../Earthworm/build.xml" />
        <ant target="jar" inheritAll="false" antfile="${root}/../Winston/build.xml" />
        <ant target="jar" inheritAll="false" antfile="${root}/../Swarm/build.xml" />
    </target>

    <target name="jar" depends="build" description="Create one large jar file">
        <jar destfile="${root}/lib/usgs.jar">
            <fileset includes="**/**.class" dir="${root}/../Util/${classdir}" />
            <fileset includes="**/**.class" dir="${root}/../Earthworm/${classdir}" />
            <fileset includes="**/**.class" dir="${root}/../Math/${classdir}" />
            <fileset includes="**/**.class" dir="${root}/../Net/${classdir}" />
            <fileset includes="**/**.class" dir="${root}/../Pinnacle/${classdir}" />
            <fileset includes="**/**.class" dir="${root}/../Plot/${classdir}" />
            <fileset includes="**/**.class" dir="${root}/../Swarm/${classdir}" />
            <fileset includes="**/**.class" dir="${root}/../Valve3/${classdir}" />
            <fileset includes="**/**.class" dir="${root}/../VDX/${classdir}" />
            <fileset includes="**/**.class" dir="${root}/../Winston/${classdir}" />
        </jar>
    </target>

    <manifest file="lib/MANIFEST.MF">
        <attribute name="Main-Class" value="gov.usgs.swarm.Swarm" />
    </manifest>

    <jar destfile="SwarmMentics.jar" manifest="lib/MANIFEST.MF">
        <zipgroupfileset dir="contrib" includes="*.jar" />
        <zipgroupfileset dir="lib" includes="*.jar" />

        <zipfileset src="contrib/colt.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/comm.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/commons-collections-3.2.1.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/commons-net-3.2.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/fissuresIDL-1.0.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/fissuresImpl-1.1.13.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/fissuresUtil-1.0.18.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/forms-1.0.7.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/h2.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/jai_codec.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/jai_core.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/JavaSeedLite.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/javassist.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/jgoodies-looks-2.5.3.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/jnlp.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/JSAP-2.1.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/jtransforms-2.4.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/log4j-1.2.13.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/looks-2.0.4.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/mysql.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/ognl-2.6.7.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/oscache-2.1-mod2.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/rrd4j-2.0.5.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/seedCodec-1.0.6.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/seedlink_lite_1.2.1.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/seedlink_lite_src_1.2.1.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/seisFile-1.5.2.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/servlet.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/slf4j-api-1.7.1.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/slf4j-log4j12-1.7.1.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="contrib/thymeleaf-2.0.13.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>

        <zipfileset src="lib/earthworm.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="lib/math.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="lib/net.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="lib/pinnacle.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="lib/plot.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="lib/swarm.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="lib/usgs.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="lib/util.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="lib/valve.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="lib/vdx.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
        <zipfileset src="lib/winston.jar">
            <exclude name="**/*.RSA, **/*.SF, **/*.DSA" />
            <exclude name="META-INF/MANIFEST.MF"/>
        </zipfileset>
    </jar>
</project>

As you see I excluded RSA,SF and DSA files and MANIFEST.MF from each jar.

如您所见,我从每个 jar 中排除了 RSA、SF 和 DSA 文件以及 MANIFEST.MF。

But it din't help me with that error.

但它不能帮助我解决这个错误。

If you know smth please reply.

如果你知道smth请回复。

Thank you!

谢谢!

回答by constantlearner

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 是用签名文件签名的。重新打包它可能会违反依赖 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.

要使其工作,您需要从已签名的 jar 中删除所有签名文件,然后再将解压缩的文件复制到最终的构建 jar 文件中。

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-shade-plugin</artifactId>
   <executions>
      <execution>
         <phase>package</phase>
            <goals>
               <goal>shade</goal>
            </goals>
      </execution>
   </executions>
   <configuration>
      <finalName>${project.artifactId}-${project.version}-uber</finalName>
      <filters>
         <filter>
            <artifact>*:*</artifact>
               <excludes>
                  <exclude>META-INF/*.SF</exclude>
                  <exclude>META-INF/*.DSA</exclude>
                  <exclude>META-INF/*.RSA</exclude>
               </excludes>
            </filter>
         </filters>
   </configuration>
</plugin>

回答by cjaube

It seems like you might be inlcuding the jars twice. First with the zipgroupfilesets and then again with a series of zipfilesets.

看起来您可能将罐子包括两次。首先使用 zipgroupfilesets,然后再次使用一系列 zipfilesets。

You could probably remove the zipgroupfilesets.

您可能会删除 zipgroupfilesets。

I believe there is also a problem in your excludes. You could change it to this:

我相信你的排除也有问题。你可以把它改成这样:

<zipfileset src="contrib/fissuresUtil-1.0.18.jar">
    <exclude name="**/*.RSA" />
    <exclude name="**/*.SF" />
    <exclude name="**/*.DSA" />
</zipfileset>

Or this:

或这个:

<zipfileset src="contrib/fissuresUtil-1.0.18.jar" excludes="**/*.RSA,**/*.SF,**/*.DSA"/>

See http://ant.apache.org/manual/Types/fileset.html(zipfileset is a form of fileset) for more information on that.

有关更多信息,请参阅http://ant.apache.org/manual/Types/fileset.html(zipfileset是一种文件集形式)。

On another note, something like this might simplify things a bit:

另一方面,像这样的事情可能会简化一些事情:

<jar destfile="SwarmMentics.jar" manifest="lib/MANIFEST.MF">
    <restrict>
        <not>
            <or>
                <name name="**/*.RSA"/>
                <name name="**/*.SF"/>
                <name name="**/*.DSA"/>
            </or>
        </not>
        <archives>
            <zips>
                <fileset dir="contrib" includes="**/*.jar"/>
                <fileset dir="lib" includes="**/*.jar"/>
            </zips>
        </archives>
    </restrict>
</jar>

I adapted this from the example at http://ant.apache.org/manual/Tasks/jar.htmlunder the "Merging archives" section.

我从http://ant.apache.org/manual/Tasks/jar.html中“合并档案”部分下的示例中改编了这一点。

回答by mojians

Just delete the *.SF file in your imported signed jar (in meta_inf folder)

只需删除导入的签名 jar 中的 *.SF 文件(在 meta_inf 文件夹中)