簡體   English   中英

Netbeans 8.0.2中的Ant文件中的錯誤反復出現,但沒有.java源錯誤

[英]Errors in Ant file in Netbeans 8.0.2 come and go but no .java source errors

我按照此過程制作了一個“胖” .jar文件,該文件在可執行.jar文件中包含外部庫。

但是由於沒有特殊的原因,我經常會在\\nbproject\\build-impl.xml兩行都出現錯誤,並且都帶有*******:

    <target depends="init,-init-macrodef-copylibs,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen" if="do.mkdist" name="-do-jar-copylibs">


********<j2seproject3:copylibs manifest="${tmp.manifest.file}"/>


        <echo level="info">To run this application from the command line without Ant, try:</echo>
        <property location="${dist.jar}" name="dist.jar.resolved"/>
        <echo level="info">java -jar "${dist.jar.resolved}"</echo>
    </target>



***************<copylibs compress="${jar.compress}" excludeFromCopy="${copylibs.excludes}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">


                    <fileset dir="${build.classes.dir}" excludes="${dist.archive.excludes}"/>
                    <manifest>
                        <attribute name="Class-Path" value="${jar.classpath}"/>
                        <customize/>
                    </manifest>
                </copylibs>

毫無疑問,錯誤是由上面鏈接中修改build.xml的過程中的說明導致的,該文件是Ant為項目創建的文件。

該過程將<target>添加到build.xml ,特別包括以下所有行:

  <target name="package-for-store" depends="jar">

        <!-- Change the value of this property to be the name of your JAR,
             minus the .jar extension. It should not have spaces.
             <property name="store.jar.name" value="MyJarName"/>
        -->

        <property name="store.jar.name" value="SCHEDULAR"/>

        <!-- don't edit below this line -->

        <property name="store.dir" value="store"/>
        <property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/>

        <echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/>

        <delete dir="${store.dir}"/>
        <mkdir dir="${store.dir}"/>

        <jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip">
            <zipgroupfileset dir="dist" includes="*.jar"/>
            <zipgroupfileset dir="dist/lib" includes="*.jar"/>

            <manifest>
                <attribute name="Main-Class" value="${main.class}"/>
            </manifest>
        </jar>

        <zip destfile="${store.jar}">
            <zipfileset src="${store.dir}/temp_final.jar"
            excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/>
        </zip>

        <delete file="${store.dir}/temp_final.jar"/>

    </target>

具體來說,對我來說相關的行是:

    <property name="store.jar.name" value="Searchy"/>

(其中Searchy是“胖” .jar文件的用戶提供的名稱)。

這是錯誤:

ant -f "C:\\Users\\Dov\\Google Drive\\NetBeansProjects\\SearchyTableSwing" -Dnb.internal.action.name=rebuild clean jar
init:
deps-clean:
Updating property file: C:\Users\Dov\Google Drive\NetBeansProjects\SearchyTableSwing\build\built-clean.properties
Deleting directory C:\Users\Dov\Google Drive\NetBeansProjects\SearchyTableSwing\build
clean:
init:
deps-jar:
Created dir: C:\Users\Dov\Google Drive\NetBeansProjects\SearchyTableSwing\build
Updating property file: C:\Users\Dov\Google Drive\NetBeansProjects\SearchyTableSwing\build\built-jar.properties
Created dir: C:\Users\Dov\Google Drive\NetBeansProjects\SearchyTableSwing\build\classes
Created dir: C:\Users\Dov\Google Drive\NetBeansProjects\SearchyTableSwing\build\empty
Created dir: C:\Users\Dov\Google Drive\NetBeansProjects\SearchyTableSwing\build\generated-sources\ap-source-output
Compiling 11 source files to C:\Users\Dov\Google Drive\NetBeansProjects\SearchyTableSwing\build\classes
compile:
Copying 1 file to C:\Users\Dov\Google Drive\NetBeansProjects\SearchyTableSwing\build
Copy libraries to C:\Users\Dov\Google Drive\NetBeansProjects\SearchyTableSwing\dist\lib.
C:\Users\Dov\Google Drive\NetBeansProjects\SearchyTableSwing\nbproject\build-impl.xml:981: The following error occurred while executing this line:
C:\Users\Dov\Google Drive\NetBeansProjects\SearchyTableSwing\nbproject\build-impl.xml:825: 
java.lang.NullPointerException
    at org.apache.tools.ant.util.ResourceUtils.copyResource(ResourceUtils.java:439)
    at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java:559)
    at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java:519)
    at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java:480)
    at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java:443)
    at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java:409)
    at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java:384)
    at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java:322)
    at org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs.execute(CopyLibs.java:206)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor284.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor284.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor284.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:435)
    at org.apache.tools.ant.Target.performTasks(Target.java:456)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
    at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:286)
    at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:555)
    at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
BUILD FAILED (total time: 1 second)

我的代碼沒有行被標記; 如果我僅運行項目(F6),就可以了。

我將tika-app-1.9.jar作為一個庫,它的體積很大,但是在該程序的早期版本中,我可以毫無問題地進行清理和構建,包括制作一個“胖” .jar文件。

對原因及其處理方法有何想法?

*編輯*

該過程的一部分是右鍵單擊build.xml (“文件”窗格),然后單擊Run targets | Run targets Other targets | package-for-store ,開始清理和構建過程。

收到錯誤消息后,如果我立即重復請求package-for-store則會出現另一個錯誤: Unable to delete file C:\\Users\\Dov\\Google Drive\\NetBeansProjects\\SearchyTableSwing\\store\\Searchy.jar 如果我自己嘗試刪除它,則必須以管理員身份進行刪除; 即使那樣我也做不到。

因此,我刪除了添加到build.xml的行,並進行了正常的清理和構建,這從store文件夾中刪除了Searchy.jar ,然后將其刪除了。

我將這些行放回build.xml並請求package-for-store並獲得了一個胖jar文件。 沒有錯誤。 正確執行。

到底是怎么回事?

一個非常糟糕的解決方法是,在請求package-for-store之前,刪除store文件夾。 到目前為止,它仍然有效。

編輯

不再。

當然,有一個需要報告的錯誤或一個更好的解決方案。

編輯

是啊。 有右的錯誤在這里的注釋也一起:

Guess it would be worth fixing in the next release :->

... and a good NPE-checker of the IDE should have detected this, too :->

2015-02-04 10:15:06 UTC This is a situation that probably doesn't happen too often - source and target location of rename are on different file systems and an IOException occurs while copying. Still it's strange it hasn't been reported before. Thanks!

looking at the sourcecode (ResourceUtils.java line:439) a null-reference for "project" must be the culprit: a) try { copyUsingFileChannels(sourceFile, destFile); copied = true; } catch (IOException ex) { project.log("Attempt to copy " + sourceFile + " to " + destFile + " using NIO Channels" + " failed due to '" + ex.getMessage() + "'. Falling back to streams.", Project.MSG_WARN); }

但這不是這里發生的事情......

b)

It would also crash in the streamCopy-fallback at the second location with a NPE because auf procect=null
    at line 439:
        private static OutputStream getOutputStream(Resource resource, boolean append, Project project)
            throws IOException {
        if (append) {
            Appendable a = resource.as(Appendable.class);
            if (a != null) {
                return a.getAppendOutputStream();
            }
            project.log("Appendable OutputStream not available for non-appendable resource "
                    + resource + "; using plain OutputStream", Project.MSG_VERBOSE);
        }
        return resource.getOutputStream();
    }

不管...需要修復的是Netbeans還是Ant或........?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM