When I try to either delete or update an existing .jar file my ant build fails with the message "Unable to delete file C:\ejb_titan\titan.jar" and "Unable to rename old file(C:\ejb_titan\titan.jar)".
I am using Windows XP and the same build file works fine on my laptop which also uses Windows XP. So I guess there is a problem with the setup of the machine I am using, but I am not able to figure it out.
BTW, I have seen the problem reported previously on this forum and also on a couple of other forums on the net but without any solution.
Any help will be much appreciated,
br Sven
Here are the jar and clean targets.
Bear Bibeault
Author and opinionated walrus
Marshal
Windows is very picky about file sharing. If it thinks something else has the file open (it's not always very good about keeping track), it will disallow the operation.
Do you have an IDE that could have the file open? A server (like Tomcat)?
No, this happens also when no IDE or Tomcat is running. So there must be some other process using the file. How can I find out which ? I need to know which process to shut down in the Windows Task Manager (ctrl+alt+del).
BTW, I noticed that I can't remove the Read Only attribute from ANY folder on my system. Is it correct that WinXP just ignores this attribute ? And is there a way to remove it, I've tried right-clicking the file and accessing the File properties dialog.
Sven
Roseanne Zhang
Ranch Hand
Joined: Nov 14, 2000
Posts: 1952
posted
0
Bear Bibeault is correct, I think. Windose makes a lot of decisions for you, even it is not always correct.
I was struggling with similar problems these two days. When ant cannot do it, then try use your hand to delete it, if you cannot, it is clear it is "Windose".
How to fight with your "Windose"? Try the followings in order: 1) Close all possible apps use that file/dir. 2) Close cmd or cygwin windows 3) Close Windows Explorer, then reopen. 4) If still not work, shut-down your PC, count 1 to 10, then start again. It worked
I am able to delete the file manually, so the problem must in some way be related to Ant.
Having to delete the file manually every time you deploy becomes extremely tedious after a while.
Sven
Joe Chitrady
Greenhorn
Joined: Jul 02, 2005
Posts: 1
posted
0
I too was struggling for a long time and finally this is the solution for me which I think is applicable to some of us. This is not related to windows have a lock on the file as the file can be renamed, deleted manually. I believe it is a bug in Ant itself.
See example below as illustration. If in your target tag your have a depends attribute to a target that refer to the jar file you want to update then you will have this issue. The solution is to remove it from the depends attribute, this would mean that you have to execute all the dependent targets manually first and then the target to build that jar file.
<target name="buildMyJar"> <<< remove the depend attribute <zip destfile="myJar.jar" basedir="${build}" includes="com/xxx/order/**" update="true"/> </target> And execute compile before buildMyJar separately. Till Ant is fixed, I think this is the best workaround.
Hope this helps. Good luck.
[ July 02, 2005: Message edited by: Joe Chitrady ] [ July 02, 2005: Message edited by: Joe Chitrady ]
Guy Allard
Ranch Hand
Joined: Nov 24, 2000
Posts: 776
posted
0
Your first suspect for what has the file locked should be your Antivirus package.
It has happened to me .......
Guy
Jerome Garcia
Greenhorn
Joined: Jan 07, 2009
Posts: 1
posted
0
Guy Allard wrote:Your first suspect for what has the file locked should be your Antivirus package.
It has happened to me .......
Guy
YES! It was indeed the Antivirus package that was causing the file conflict for me as well. Disabling the realtime antivirus scanning is what completely solved the problem for me!
Guy Allard wrote:Your first suspect for what has the file locked should be your Antivirus package.
It has happened to me .......
Guy
YES! It was indeed the Antivirus package that was causing the file conflict for me as well. Disabling the realtime antivirus scanning is what completely solved the problem for me!
Amazing.
also i'll recommend to check wid file permissions before deleting them...
Incidentally, Windows has a very pessimistic file locking mechanism, and unlike Unix, it locks on the file's name, not on the directory node. So I think you'll find you can't rename a locked file.
In fact, that's one of the reasons why Windows is so obsessive about reboots related to software installation, Less constricted OS's would typically rename or delete a "dll" that needed replacing, copy in the new DLL, then set up for actual deletion when the old one was unlocked (generally at reboot).. Since the lock is on the name and not the data, Windows doesn't have that luxury. Instead the new DLL is queued up and installed during the reboot process before the locks are established.
One of the most odious afflictions that Business has inflicted on the modern English language is "pro-active". Most of the time it's simply redundantly used in place of the simple old word "active". And a good deal of the rest of the time it means "You're not overworked enough yet, so go out and find more!"
Otto Kar
Greenhorn
Joined: Mar 22, 2011
Posts: 1
posted
0
Thanks Tim,
your post saved my day. I could solve the problem.
What I learnt:
If you use any classpath in any target of your build on your Windows(!) machine,
you should never try to delete any of the jars that are used in these classpaths
at any time later during this Ant build because all the jars remain locked.
If you think your problem is another one, double-check this scenario by starting your build
with option -version and scan the output for "class" or the name of your jar file.
You might be surprised.
Good luck!
php gen
Greenhorn
Joined: Jan 02, 2012
Posts: 1
posted
1
Hii,I was having these same issues when i got this same error till i found this tool