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 212164 - Unable to delete dist\any.jar
Summary: Unable to delete dist\any.jar
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 7.1
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Assignee: Tomas Zezula
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-07 18:22 UTC by sandrovalgoi
Modified: 2016-06-23 07:36 UTC (History)
4 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 sandrovalgoi 2012-05-07 18:22:24 UTC
Product Version = NetBeans IDE 7.1.2 (Build 201204101705)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.7.0_04
Runtime = Java HotSpot(TM) 64-Bit Server VM 23.0-b21

I have a java project stored at C:\Users\SandroV\Documents\NetBeansProjects\JbNfse, here project A;
I have a java library project at C:\Users\SandroV\Documents\NetBeansProjects\libNotaClientBetha, here project B;
I have a folder temp into c:\users\username\documents\netbeansprojects.
When I open any file from temp folder (maybe on Notepad) and I try to compile the A project  then I get a error that can't delete a file from B project .
I need to close the file from temp folder to make possible to compile.

libNotaClientBetha.init:
libNotaClientBetha.deps-clean:
Updating property file: C:\Users\SandroV\Documents\NetBeansProjects\JbNfse\build\built-clean.properties
Deleting directory C:\Users\SandroV\Documents\NetBeansProjects\libNotaClientBetha\build
C:\Users\SandroV\Documents\NetBeansProjects\JbNfse\nbproject\build-impl.xml:1034: The following error occurred while executing this line:
C:\Users\SandroV\Documents\NetBeansProjects\JbNfse\nbproject\build-impl.xml:1060: The following error occurred while executing this line:
C:\Users\SandroV\Documents\NetBeansProjects\libNotaClientBetha\nbproject\build-impl.xml:1030: Unable to delete file C:\Users\SandroV\Documents\NetBeansProjects\libNotaClientBetha\dist\libNotaClientBetha.jar
FALHA NA CONSTRUÇÃO (tempo total: 0 segundos)
Comment 1 s.alcaino 2013-01-03 19:52:56 UTC
I have the same issue with NetBeans IDE 7.2 (Build 201207171143) on Windows XP

Whenever i try to clean and build, it will fail 3 different times, with 3 different jar files.
at the 4th try works just fine.
It's not that bad, but it's getting annoying.

Thanks!

Sebastian Alcaino

this is the line that's failing on the build-impl.xml file

<delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/>
Comment 2 AlainD 2013-01-22 11:06:42 UTC
Same problem for me with NetBeans IDE 7.2.1 (Build 201210100934).

No way to compile applet because the previous version is not deleted.
No way to delete myFile.jar in Windows nor DOS neither.

DOS diagnostic: This file is being used by another process.
Windows diagnostic : This file is open in Java(TM) platform SE library.

Please check that Netbeans closes the file after building.
Comment 3 AlainD 2013-01-22 12:16:05 UTC
On second analysis, it seams that the process locking the file for deletion is the browser.

I am using Chrome, and when I close Chrome totally (not only the tab but the application) then Netbeans builds the jar perfectly.
Comment 4 richwilsonaus 2014-02-05 01:54:36 UTC
I have a large set of projects with a custom build script. This error occurs for me all the time due to the IDE itself initiating a "Background Scan" as soon as I start a "Clean and Build". The Background Scan opens JAR files under Windows, then the "Clean" part of the build fails with "Unable to delete file". In my opinion, the background scan should not start until after a build is complete, and if it's currently in progress, it should be paused (with no files open) and restarted after the build is complete. As it currently stands, you can't even pause or stop the "Background Scan" at all.
Comment 5 choekstra 2014-06-10 05:19:57 UTC
For me, this happens when I forget to stop the server before a compile/build. 

In NetBeans, go to the Services tab, right-click your server, and stop it. That might be the process that's holding onto the file/folder that the build process can't delete. 

Sometimes people used to standalone Eclipse or Websphere IDE's assume the server likewise gets restarted by default in NetBeans -- it doesn't.
Comment 6 Tomas Zezula 2014-06-10 07:09:55 UTC
According to comment 5 it seems that the handler is held by web server.
Reassigning to web server integration.
Comment 7 richwilsonaus 2014-06-18 00:13:02 UTC
@Tomas, this bug has nothing to do with web server for me, it is simply that the "Clean and Build" triggers a background scan (of every project) as soon as some files in one project are deleted. If I do a separate "Clean" first, then a "Build" the clean manages to finish before the background scan locks the files.
Comment 8 David Konecny 2014-07-09 02:02:03 UTC
Clean on Web/EE Projects undeploys app from the server first so it should not be a server issue. Most of the comments do not refer to Web app nor server either. Sorry I'm passing back.
Comment 9 Tomas Zezula 2016-06-23 07:36:46 UTC
When the project depends on the library project the IDE does not use the library jar for resolution (it does not open it), it rather uses caches created for library sources. However the IDE opens the library jar to lookup annotation processors. The IDE overrides the Ant <delete> task to mutually exclude processors lookup and deletion of the jar file. There was one missing place where exclusion was needed which was fixed in dev build Jun 3, 2016 jet-main 2f4bac15b236. So should be fixed now.

However we have several similar reports where the jar was opened by some external process not the IDE.
Please if the problem happens even with current dev build try to find the process holding the affected jar file using the sysinternals process monitor https://technet.microsoft.com/en-us/sysinternals/processmonitor.aspx.

Thanks!


Fixed jet-main 2f4bac15b236