Surefire cancelled, can't remove locked target folder

I ran into this annoying issue on windows: I cancelled a running junit test in maven (it was hanging), but could not rerun maven. It complained that the target folder could not be deleted.

A file created by the surefire plugin in maven was locked, apparently some process was still using it. On unix you can use the fuser command to determine which process is using the file, windows (xp) doesn’t have something similar as far i know. But you can use the handle tool.

Running handle returned the following information:

C:javaproject1>handle -u target

Handle v3.42
Copyright (C) 1997-2008 Mark Russinovich
Sysinternals - www.sysinternals.com

java.exe           pid: 3724   RWDakoelewijn            5F0: C:javaproject1targetsurefire-reportsMyTest.t
xt

Now i know what process to kill in the Windows Task Manager to free the lock, 3724. However, java.exe is not very specific, so before killing it, i wanted to know what java program was causing the problem. You can use the jps program to get more information about java processes.

C:javaproject1>jps -mlvV
1980 sun.tools.jps.Jps -mlvV -Dapplication.home=c:javajdk1.6.0_19 -Xms8m
3724 C:DOCUME~1AKOELE~1LOCALS~1Tempsurefirebooter1746354547445203551.jar C:DOCUME~1AKOELE~1LOCALS~1Tempsurefire839466388449137286tmp C:DOCUME~1AKOELE~1LOCALS~1Tempsurefire59221631739070
63713tmp

The output of jps shows me that Jps itself is running and a jar called surefirebooter*.jar.

blog comments powered by Disqus