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

时间:2013-11-18 10:41:58

标签: java security ant

我在其他帖子中尝试过建议,但他们没有帮助我。 当我按java -jar -BigJar.jar运行我的jar时,我收到异常:

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

我的蚂蚁文件是

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

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

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

如果你知道smth,请回复。

谢谢!

3 个答案:

答案 0 :(得分:5)

好像你可能会两次包装罐子。首先使用zipgroupfilesets,然后再使用一系列zipfilesets。

您可以删除zipgroupfilesets。

我相信你的排除也存在问题。 您可以将其更改为:

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

或者这个:

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

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

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

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

我在“合并档案”部分下的http://ant.apache.org/manual/Tasks/jar.html示例中对此进行了调整。

答案 1 :(得分:4)

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

要使其正常工作,您需要从已签名的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>

答案 2 :(得分:0)

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