代码之家  ›  专栏  ›  技术社区  ›  Alastair Brayne

ant build类路径jar生成“打开zip文件时出错”

  •  6
  • Alastair Brayne  · 技术社区  · 16 年前

    我有一个在Eclipse中构建的项目,它依赖于第三方JAR。我正在尝试为Ant生成一个合适的构建文件—使用Eclipses内置的导出—Ant构建文件功能作为起始块。

    当我运行生成目标时,得到以下错误:

    [javac] error: error reading /base/repo/FabTrace/lib/apache/geronimo/specs/geronimo-j2ee-management_1.0_spec/1.0/geronimo-j2ee-management_1.0_spec-1.0.jar; error in opening zip file
    

    整个构建文件(由Eclipse自动生成)如下所示: (注意:上面的错误总是引用类路径中列出的第一个JAR)

    <project basedir="." default="build" name="FabTrace">
        <property environment="env"/>
        <property name="ECLIPSE_HOME" value="/opt/apps/eclipse"/>
        <property name="debuglevel" value="source,lines,vars"/>
        <property name="target" value="1.5"/>
        <property name="source" value="1.5"/>
        <path id="JUnit 4.libraryclasspath">
            <pathelement location="${ECLIPSE_HOME}/plugins/org.junit4_4.5.0.v20090824/junit.jar"/>
            <pathelement location="${ECLIPSE_HOME}/plugins/org.hamcrest.core_1.1.0.v20090501071000.jar"/>
        </path>
        <path id="FabTrace.classpath">
            <pathelement location="bin"/>
            <pathelement location="lib/apache/geronimo/specs/geronimo-j2ee-management_1.0_spec/1.0/geronimo-j2ee-management_1.0_spec-1.0.jar"/>
            <pathelement location="lib/apache/geronimo/specs/geronimo-jms_1.1_spec/1.0/geronimo-jms_1.1_spec-1.0.jar"/>
            <pathelement location="lib/commons-collections/commons-collections/3.2/commons-collections-3.2.jar"/>
            <pathelement location="lib/commons-io/commons-io/1.4/commons-io-1.4.jar"/>
            <pathelement location="lib/commons-lang/commons-lang/2.1/commons-lang-2.1.jar"/>
            <pathelement location="lib/commons-logging/commons-logging/1.1/commons-logging-1.1.jar"/>
            <pathelement location="lib/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar"/>
            <pathelement location="lib/javax/activation/activation/1.1/activation-1.1.jar"/>
            <pathelement location="lib/javax/jms/jms/1.1/jms-1.1.jar"/>
            <pathelement location="lib/javax/mail/mail/1.4/mail-1.4.jar"/>
            <pathelement location="lib/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar"/>
            <pathelement location="lib/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar"/>
            <pathelement location="lib/junit/junit/4.4/junit-4.4.jar"/>
            <pathelement location="lib/log4j/log4j/1.2.15/log4j-1.2.15.jar"/>
            <pathelement location="lib/apache/camel/camel-jms-2.0-M1.jar"/>
            <pathelement location="lib/spring/spring-2.5.6.jar"/>
            <pathelement location="lib/apache/camel/camel-bundle-2.0-M1.jar"/>
            <pathelement location="lib/backport-util-concurrent/backport-util-concurrent-3.1.jar"/>
            <pathelement location="lib/commons-pool/commons-pool-1.4.jar"/>
            <pathelement location="lib/apache/camel/camel-activemq-1.1.0.jar"/>
            <pathelement location="lib/apache/activemq/activemq-camel-5.2.0.jar"/>
            <pathelement location="lib/jencks/jencks-2.2-all.jar"/>
            <pathelement location="lib/jencks/jencks-amqpool-2.2.jar"/>
            <pathelement location="lib/activemq/apache-activemq-5.3.1/activemq-all-5.3.1.jar"/>
            <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/optional/xbean-spring-3.6.jar"/>
            <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/activemq-core-5.3.1.jar"/>
            <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/camel-jetty-2.2.0.jar"/>
            <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/web/jetty-6.1.9.jar"/>
            <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/web/jetty-util-6.1.9.jar"/>
            <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/web/jetty-xbean-6.1.9.jar"/>
            <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/optional/activemq-optional-5.3.1.jar"/>
            <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/web/geronimo-servlet_2.5_spec-1.2.jar"/>
            <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/optional/spring-beans-2.5.6.jar"/>
            <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/optional/spring-context-2.5.6.jar"/>
            <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/optional/spring-core-2.5.6.jar"/>
            <path refid="JUnit 4.libraryclasspath"/>
        </path>
        <target name="init">
            <mkdir dir="bin"/>
            <copy includeemptydirs="false" todir="bin">
                <fileset dir="src/main/java">
                    <exclude name="**/*.launch"/>
                    <exclude name="**/*.java"/>
                </fileset>
            </copy>
            <copy includeemptydirs="false" todir="bin">
                <fileset dir="src/test/java">
                    <exclude name="**/*.launch"/>
                    <exclude name="**/*.java"/>
                </fileset>
            </copy>
            <copy includeemptydirs="false" todir="bin">
                <fileset dir="config">
                    <exclude name="**/*.launch"/>
                    <exclude name="**/*.java"/>
                </fileset>
            </copy>
        </target>
        <target name="clean">
            <delete dir="bin"/>
        </target>
        <target depends="clean" name="cleanall"/>
        <target depends="build-subprojects,build-project" name="build"/>
        <target name="build-subprojects"/>
        <target depends="init" name="build-project">
            <echo message="${ant.project.name}: ${ant.file}"/>
            <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
                <src path="src/main/java"/>
                <classpath refid="FabTrace.classpath"/>
            </javac>
            <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
                <src path="src/test/java"/>
                <classpath refid="FabTrace.classpath"/>
            </javac>
            <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
                <src path="config"/>
                <classpath refid="FabTrace.classpath"/>
            </javac>
        </target>
    
    </project>
    

    (我知道这里有Eclipse特有的东西。但不管有没有它,我都能得到同样的结果。)

    我已经完成了你们的旧谷歌搜索,没有成功地四处搜索。

    我可以确认所有的罐子确实存在。我也尝试过从命令行和作为sudo-再次,同样的结果。

    任何帮助都将不胜感激。

    干杯

    2 回复  |  直到 14 年前
        1
  •  3
  •   Alastair Brayne    14 年前

    根据马丁·克莱顿的建议,我之前的评论被复制到下面作为答案。

    “叹息。我想是因为我移除了最初引起这个问题的第一个罐子(我甚至不相信我真的需要它们了),问题就转移到了下一个罐子……嗯,这让我怀疑是系统性故障。事实上我在课堂上有很多垃圾桶。一定是把下载搞砸了。不管怎样,现在都修好了。干杯

        2
  •  0
  •   bakoyaro CoreyRDean    15 年前

    有没有 <filterset/> 在构建文件中的任何复制语句中?我曾经遇到过一个问题 <copy> “ing” **/* “在开发接近尾声时,我发现了如何使用 <滤波器组/GT; 具有 <复制> .

    长话短说来,文本替换工作完美无瑕,但其中包含的任何二进制文件、可执行文件或.jar ** “这条路被彻底摧毁了。它们不是以二进制模式打开文件,而是以文本模式打开,然后以文本模式保存。

    如果你有 <滤波器组/GT; 或者构建文件中类似的地方,请确保 <exclude/> 任何和所有二进制文件。

    推荐文章