vendredi 16 septembre 2016

Netbeans locks jar file after testing: can not clean

I have two fairly simple Java projects in Netbeans 8.1 with Ant under Windows 7 without any glassfish or tomcat servers. One project is using the other one as a compile-time library.

If I start Netbeans and clean and build the library or the dependent project, everything works fine, also for multiple clean and build runs.

I use JUnit 4.12 in combination with harmcrest-1.3 and TESTNG to test several unit tests. All individual tests for both projects are passed. For the library project I can clean and build, run tests and clean and build afterwards without any problems.

Now my problem: After I run the tests of the dependent project, I can not clean the project or the library project anymore. If I perform clean after the tests I get:

PATH\build-xml:LINENR: The following error occurred while executing this line:

multiple times and finally:

PATH\build-xml:LINENR: Unable to delete file PATH\LIBRARYPROJECT.jar

I also cannot delete the dist\ folder or LIBRARYPROJECT.jar individually from the explorer. I used procmon as explained in this thread to find out which program locks the jar file. To my surprise it is Netbeans itself. If I try to delete the file manually I get an error that the jar file is used by NetBeans and procmon says:

enter image description here

Is there something I am missing? Why does performing tests create a lock on jar files? How can I get rid of that lock without having to restart NetBeans everytime?

Aucun commentaire:

Enregistrer un commentaire