简体   繁体   English

Ant 1.9.4不会使用Java 8清理和构建Netbeans 8.0.2项目。 给出空指针异常

[英]Ant 1.9.4 won't clean and build Netbeans 8.0.2 project using Java 8; gives null pointer exception

My code has no errors. 我的代码没有错误。 If I choose F6 (Run) it executes fine. 如果我选择F6(运行),它将正常执行。 If I Clean it, there are no errors. 如果我清洁它,则没有错误。 But if I clean and build, I get these errors because of bug(s) in Netbeans 8.0.2 and/or Ant 1.9.4. 但是,如果我清理并构建,则由于Netbeans 8.0.2和/或Ant 1.9.4中的错误而出现这些错误。 The completely unacceptable workaround is to create a new project and copy all the files into it. 完全不可接受的解决方法是创建一个新项目并将所有文件复制到其中。 This works for awhile. 这工作了一段时间。 Then I have to do it again. 然后我必须再做一次。

EDIT 编辑

I use tika-app-1.9.jar as library file. 我使用tika-app-1.9.jar作为库文件。 It is 45MB. 45MB。 If I remove it and instead use tika-parsers-1.10.jar and tika-core-1.10.jar as library files, I don't get this error BUT my program then can't properly process .PDF files. 如果删除它,而是使用tika-parsers-1.10.jartika-core-1.10.jar作为库文件,则我的程序没有收到此错误,因此无法正确处理.PDF文件。 And with the huge library, the program has compiled successfully dozens of times and run as standalone (ie, outside Netbeans) many more times. 有了庞大的库,该程序已经成功编译了数十次,并且可以独立运行(即在Netbeans之外)运行多次。

END OF EDIT 编辑结束

EDIT 2 编辑2

OK. 好。 I deleted replaced the two smaller library files with tika-app-1.10.jar and clean and build WORKED. 我删除了用tika-app-1.10.jar替换两个较小的库文件,然后清理并构建WORKED。

ONCE. 一旦。

END EDIT 结束编辑

Please offer some insight into why it's happening and how to fix and prevent it or otherwise debug it. 请提供一些有关为什么发生这种情况的信息,以及如何解决和阻止它或对其进行调试的一些见解。 I have over 3000 lines of debug output but the bottom line, whether debug is selected or not is always these: 我有超过3000行的调试输出,但无论是否选择调试,最重要的始终是这些:

C:\Users\Dov\Google Drive\NetBeansProjects\Find\nbproject\build-impl.xml:994: The following error occurred while executing this line:
C:\Users\Dov\Google Drive\NetBeansProjects\Find\nbproject\build-impl.xml:838: 
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)

Here's my project: 这是我的项目:

在此处输入图片说明 在此处输入图片说明

I haven't messed with build.xml or any other generated files. 我没有弄混build.xml或任何其他生成的文件。

I've restarted Netbeans 8.0.2 and looked for instances of JVM that might be running. 我重新启动了Netbeans 8.0.2,并寻找了可能正在运行的JVM实例。 There aren't. 没有。

Here's the Ant screen: 这是Ant屏幕:

在此处输入图片说明

Here's more of the stack trace: 这是堆栈跟踪的更多信息:

    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.GeneratedMethodAccessor61.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.GeneratedMethodAccessor61.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.GeneratedMethodAccessor61.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: 4 seconds)

Please note these lines that FOLLOW the BUILD FAILED line: 请注意以下BUILD FAILED行:

Could not load class (org.apache.tools.ant.taskdefs.repository.MavenRepository) for type mavenrepository
Could not load a dependent class (jdepend/xmlui/JDepend) for type jdepend
Could not load a dependent class (javax/media/jai/PlanarImage) for type image
Could not load class (org.apache.tools.ant.taskdefs.repository.MavenRepository) for type mavenrepository
Could not load a dependent class (jdepend/xmlui/JDepend) for type jdepend
Could not load a dependent class (javax/media/jai/PlanarImage) for type image

Checking the related ResourceUtils , it seems the exception is occurring in a copy task (probably the one copying your library Jar file), specifically when trying to log an error before falling back to another copy mechanism. 检查相关的ResourceUtils ,似乎在复制任务(可能是复制您的库Jar文件的一个复制任务)中发生了异常,特别是在尝试回退到另一个复制机制之前记录错误时。

Meanwhile checking Ant 1.9.5, it seems the problem was fixed, and the release notes mention this in Bug 57533 ( NullPointerException FileUtil.rename / ResourceUtils.copyFile() if copyUsingFileChannels failed ). 同时检查Ant 1.9.5,看来问题已解决,并且发行说明Bug 57533中提到了此问题(如果copyUsingFileChannels失败, 则为 NullPointerException FileUtil.rename / ResourceUtils.copyFile() )。

Therefore, I would try to upgrade to Ant 1.9.5 to see if the problem is resolved. 因此,我将尝试升级到Ant 1.9.5,以查看问题是否得到解决。

I downloaded Ant 1.9.6 and made Netbeans use it as shown in the screen shot. 我下载了Ant 1.9.6,并使Netbeans使用它,如屏幕快照所示。

No problem with the error and huge library .jar after 3 quick clean and builds. 经过3次快速清理和构建,错误和庞大的库.jar都没问题。

在此处输入图片说明

Then: a different error: 然后:另一个错误:

Attempt to copy C:\Users\Dov\Downloads\tika-app-1.10.jar to C:\Users\Dov\Google Drive\NetBeansProjects\Find\dist\lib\tika-app-1.10.jar using NIO Channels failed due to 'C:\Users\Dov\Google Drive\NetBeansProjects\Find\dist\lib\tika-app-1.10.jar (Access is denied)'.  Falling back to streams.
C:\Users\Dov\Google Drive\NetBeansProjects\Find\nbproject\build-impl.xml:994: The following error occurred while executing this line:
C:\Users\Dov\Google Drive\NetBeansProjects\Find\nbproject\build-impl.xml:838: 
java.io.FileNotFoundException: C:\Users\Dov\Google Drive\NetBeansProjects\Find\dist\lib\tika-app-1.10.jar (Access is denied)
    at java.io.FileOutputStream.open0(Native Method)

EDIT 编辑

The project folder, the dist folder, the lib folder, and the .jar library file all had red Xs on them. 项目文件夹,dist文件夹,lib文件夹和.jar库文件上都带有红色的X。 Only way to proceed: shut down Windows and then the .jar file goes away; 唯一可行的方法:关闭Windows,然后.jar文件消失; clean and build works again--but for how long. 清理并重新构建可以工作-但要持续多长时间。 Period. 期。

Pretty inconvenient to not be able to delete the .jar file other than shutdown. 除了关机以外,无法删除.jar文件非常不便。

Hope the bug gets fixed soon. 希望该错误能尽快得到解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM