This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 229103 - Compiling Java-Project stops sometimes with Error by deleteing build-dir
Summary: Compiling Java-Project stops sometimes with Error by deleteing build-dir
Status: RESOLVED INCOMPLETE
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 7.3
Hardware: PC Windows 7 x64
: P2 normal (vote)
Assignee: Tomas Zezula
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-27 12:54 UTC by MrMacSpooky
Modified: 2013-06-06 08:12 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description MrMacSpooky 2013-04-27 12:54:02 UTC
By Compilling a Java-Project IDE deletes its build-dir.

Often, not every time, the following error occurs:

##
ant -f C:\\Users\\user\\Documents\\NetBeansProjects\\YaHRC clean jar
init:
deps-clean:
Updating property file: C:\Users\user\Documents\NetBeansProjects\YaHRC\build\built-clean.properties
Library.init:
Library.deps-clean:
Updating property file: C:\Users\user\Documents\NetBeansProjects\YaHRC\build\built-clean.properties
Deleting directory C:\Users\user\Documents\NetBeansProjects\Library\build
C:\Users\user\Documents\NetBeansProjects\YaHRC\nbproject\build-impl.xml:1389: The following error occurred while executing this line:
C:\Users\user\Documents\NetBeansProjects\YaHRC\nbproject\build-impl.xml:1418: The following error occurred while executing this line:
C:\Users\user\Documents\NetBeansProjects\Library\nbproject\build-impl.xml:1385: Unable to delete file C:\Users\user\Documents\NetBeansProjects\Library\dist\Library.jar
BUILD FAILED (total time: 0 seconds)
##

Normally I press a few Times on 'Clean and Build' if this problem exists. Sometimes one more time is enough - sometimes up to 4 times are needed.

Might be a delayed File-Lock!?
Comment 1 Tomas Zezula 2013-06-04 15:12:42 UTC
In fact the NB does not touch the lib/dist. It just copies the jars into it using the Ant's FileUtils.copyFile() which always closes the output stream. There are two possibilities:

1st) Other program is holding a handle to file.
2nd) There is some wrongly set up project depending on the dist/lib/Library.jar rather than depending on the library project.

To verify which case is true you can use the Process Exlorer from http://technet.microsoft.com/en-us/sysinternals/bb896653.
Comment 2 Tomas Zezula 2013-06-04 15:14:44 UTC
If possible can you provide as the project causing such a problem.
Thanks!
Comment 3 MrMacSpooky 2013-06-04 15:33:43 UTC
(In reply to comment #2)

Mmh, it's just as easy - because this happens with a Simple Project, created by the Wizzard (one Class, one Method) - nothing special.

These Filelockings appears with Windows 7 Ultimate 64Bit (other Win-plafs I don't know - with ubuntu this didn't happen).

For the first times it Compiles and Builds fine, than, a little bit later the same process will abort about 2-3 times with this error-log. ReClicking the Build normally succeeds.

You may run into trouble the best way, when you perform small changes - which you will directy apply by compiling. you might be run into better trouble having some more classes - it seems to be a 'runtime'-bahaviour.

How I said, it might be a Locking-Problem with Windows. Might it be, that windows needs some time before ANT can be sure, the directory is gone (as i saw, the process (build) RMDIRs the directory, creates a new one and build the jar (and if needed, it copies libs to there)).
Comment 4 Tomas Zezula 2013-06-05 11:31:28 UTC
I've did some more testing and probably found the root problem.
The problem is a javac which does not close jar file as it uses newio 2 (Path api).
It can be seen from the following DTrace log logging syscall::open syscall::close on Mac.

2    150                      open:return Process mdworker (15206) opened file: /Users/tom/NetBeansProjects/Library/dist/lib/AbsoluteLayout.jar(4)
  2    151                      close:entry Process mdworker (15206) closes file /Users/tom/NetBeansProjects/Library/dist/lib/AbsoluteLayout.jar(4)
  0    150                      open:return Process javac (15223) opened file: /Users/tom/NetBeansProjects/Library/dist/lib/AbsoluteLayout.jar(19)
  0    151                      close:entry Process javac (15223) closes file /Users/tom/NetBeansProjects/Library/dist/lib/AbsoluteLayout.jar(19)
  0    150                      open:return Process javac (15223) opened file: /Users/tom/NetBeansProjects/Library/dist/lib/AbsoluteLayout.jar(20)
  1    150                      open:return Process javac (15223) opened file: /Users/tom/NetBeansProjects/Library/dist/lib/AbsoluteLayout.jar(21)
  1    151                      close:entry Process javac (15223) closes file /Users/tom/NetBeansProjects/Library/dist/lib/AbsoluteLayout.jar(21)
Comment 5 Tomas Zezula 2013-06-05 14:09:18 UTC
Some more questions what JDK are you using for the project (Project Properties/Libraries/Java Platform)?
Is it default platform or non default platform? Which version?
Thanks!
Comment 6 MrMacSpooky 2013-06-05 15:48:59 UTC
(In reply to comment #5)

I'm using JDK 1.7.0_21 - from Oracle; 64 Bit for Windows.

By Setting-Up a Project, I activate the following:
Build
 Compiling
  Report Uses of Deprecated APIs
  Track Java Dependencies
   Enable Annotation Processing in Editor
   (but none are added)
  Additional Compiler Options: '-Xlint:unchecked'
  (for some more warnings)
 Packaging
  Compress JAR File
  (deactivate) Copy Dependent Libs
 Documenting
  (activate all other Check-Boxes)

If I use Libs, they may be other Netbeans-Projects or often the mysql-driver; but this problem exists undependend on libs - it exists with plain java-code; no libs, no resources - just simple code. But it happens on a not regular base (sporadic).
Comment 7 Tomas Zezula 2013-06-06 07:43:28 UTC
More update: Using syscall tracing it seems that javac non closed handler is a problem just on JDK 8 it does not affect JDK 7. The JDK 7 javac closes all file handles. Also the problem on Windows can be reproduced even when the javac has fork="true" and creates a new external process which terminates after compilation. Hopefully Windows is able to free the resources for terminated process as soon as it's removed from process list.
Comment 8 Tomas Zezula 2013-06-06 08:12:45 UTC
Here is a list what did not helped:

1st) -J-Dsun.zip.disableMemoryMapping=true - preventing mmap() which depends on GC

2nd) performGCOnFailedDelete

3rd) empty processor path + disable processors

4th) disable copylibs