1

My code has no errors. If I choose F6 (Run) it executes fine. 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. 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. It is 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. And with the huge library, the program has compiled successfully dozens of times and run as standalone (i.e., outside Netbeans) many more times.

END OF EDIT

EDIT 2

OK. I deleted replaced the two smaller library files with tika-app-1.10.jar and clean and build 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:

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:

enter image description hereenter image description here

I haven't messed with build.xml or any other generated files.

I've restarted Netbeans 8.0.2 and looked for instances of JVM that might be running. There aren't.

Here's the Ant screen:

enter image description here

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:

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
DSlomer64
  • 4,234
  • 4
  • 53
  • 88

2 Answers2

1

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.

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

Therefore, I would try to upgrade to Ant 1.9.5 to see if the problem is resolved.

M A
  • 71,713
  • 13
  • 134
  • 174
  • @manouti--Thank you very much. I am hopeful that you are correct about this solving my problem. I have downloaded Ant 1.9.6 but how do I make Netbeans use it? When I have it check for updates, it doesn't find any. I note that where Netbeans currently finds Ant (`C:\Program Files\NetBeans 8.0.1\extide\ant`) there are FOUR folders but the Ant download only has 3. The extra folder is `nblib`, which is no doubt "NetBeansLIB", and without also downloading it from somewhere, I don't think it's going to work. – DSlomer64 Aug 21 '15 at 20:22
  • @DSlomer64 I don't use NetBeans but [this post](http://stackoverflow.com/questions/12901499/netbeans-change-ant-version) may be useful. – M A Aug 21 '15 at 20:28
0

I downloaded Ant 1.9.6 and made Netbeans use it as shown in the screen shot.

No problem with the error and huge library .jar after 3 quick clean and builds.

enter image description here

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. Only way to proceed: shut down Windows and then the .jar file goes away; clean and build works again--but for how long. Period.

Pretty inconvenient to not be able to delete the .jar file other than shutdown.

Hope the bug gets fixed soon.

DSlomer64
  • 4,234
  • 4
  • 53
  • 88