Bug 49117

Summary: Unable to rename old file to temporary file JAR TASK
Product: Ant Reporter: Arinjay <arinjaybaj>
Component: Core tasksAssignee: Ant Notifications List <notifications>
Status: NEW ---    
Severity: critical    
Priority: P2    
Version: 1.8.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Bug Depends on:    
Bug Blocks: 51069    
Attachments: passing test
test using antcall

Description Arinjay 2010-04-14 05:07:16 UTC
While trying to add manifest to the jar file, the JAR task fails with the error:
"Unable to rename old file <> to temporary file."

This was an upgrade from jdk1.5 to jdk1.6. The build works fine with the jdk1.5.
Comment 1 Stefan Bodewig 2010-04-16 16:35:49 UTC
Are you using an operating system that locks files that are open (like
Windows)?

If you've just created the jar and then try to update it in a subsequent task
the file may not have been closed properly - in this case
this would be a duplicate of bug 45960 and is supposed to be fixed
with Ant 1.8.0.
Comment 2 Stefan Bodewig 2010-04-22 06:35:16 UTC
Could you please try Ant 1.8.0 and report back?
Comment 3 Arinjay 2010-04-22 07:52:39 UTC
(In reply to comment #2)
> Could you please try Ant 1.8.0 and report back?

I did tried with Ant 1.8.0 and I am getting the same issue. However, if I am facing that only in the case of a manifest update.
If I remove the target which updates the manifest, then the script completes but I fail with classnotfoundexceptions as the manifest is not updated with the appropriate classpaths.

Can you please help?
Comment 4 Stefan Bodewig 2010-04-22 08:00:25 UTC
It would be good if you could provide a small testcase build file, I'll give it a try myself.

Are you running Windows?
Comment 5 Stefan Bodewig 2010-04-22 08:04:49 UTC
Created attachment 25335 [details]
passing test

The attached test file works fine for me (Java6 on Windows 7).
Comment 6 Arinjay 2010-04-22 08:10:47 UTC
(In reply to comment #5)
> Created an attachment (id=25335) [details]
> passing test
> 
> The attached test file works fine for me (Java6 on Windows 7).


I am running Java6 on Win Xp Professional SP3.

<jar jarfile="${file.input}" update="yes">
<manifest>
<attribute name="Class-Path" value="${lib.path} ${manifest.default.classpath}"/>
</manifest>
</jar>
Comment 7 Stefan Bodewig 2010-04-22 08:19:33 UTC
does my attached build file cause any problems for you?
Comment 8 Arinjay 2010-04-22 08:48:02 UTC
(In reply to comment #7)
> does my attached build file cause any problems for you?

The file which you have shared works well with 1.6.5 as well.
Comment 9 Stefan Bodewig 2010-04-22 09:02:29 UTC
so what is different in your case?
Comment 10 Stefan Bodewig 2010-04-23 03:43:44 UTC
In case my last question sounded a bit rude, sorry about that, that wasn't intended.

In order to fix the problem you see, we will need to figure out what the difference between your testcase and my minimal snippet is.  In an ideal world we'd be able to distill a reproducable testcase.

I understand you won't be able to provide us with the full build environment you are using.  If you don't manage to trim it down to the problem, maybe a start could be if you provided us with the -debug log of your build process when it fails using Ant 1.8.0.

If even the logfile would reveal sensitive information than feel free to send it to me in private email rather than attaching it to the issue.
Comment 11 Arinjay 2010-04-23 05:07:27 UTC
(In reply to comment #10)
> In case my last question sounded a bit rude, sorry about that, that wasn't
> intended.
> 
> In order to fix the problem you see, we will need to figure out what the
> difference between your testcase and my minimal snippet is.  In an ideal world
> we'd be able to distill a reproducable testcase.
> 
> I understand you won't be able to provide us with the full build environment
> you are using.  If you don't manage to trim it down to the problem, maybe a
> start could be if you provided us with the -debug log of your build process
> when it fails using Ant 1.8.0.
> 
> If even the logfile would reveal sensitive information than feel free to send
> it to me in private email rather than attaching it to the issue.

Let me give a try to produce a similar one and we can try reproducing it at your end.
Comment 12 Arinjay 2010-04-23 06:02:01 UTC
Does this give any idea which we can try?

 <target name="ear.create" depends="ear.environment.setup">
        <antcall target="jar.create"/>
        <antcall target="manifest.create"/> <<<It fails here>>>
	After the updation of manifest above and executing the other targets, it creates the ear.
	<ear >
	</ear>
<target>
Comment 13 Stefan Bodewig 2010-04-23 07:01:11 UTC
Created attachment 25341 [details]
test using antcall

I'm afraid the antcall layer isn't enough to cause problems - the attached build file still works for me.
Comment 14 Arinjay 2010-05-07 10:37:57 UTC
(In reply to comment #13)
> Created an attachment (id=25341) [details]
> test using antcall
> 
> I'm afraid the antcall layer isn't enough to cause problems - the attached
> build file still works for me.

Sorry for the delay!
I will require your email id ...will not be possible to send you the build but will try to reproduce something similar.
Comment 15 Arinjay 2010-05-07 10:41:14 UTC
(In reply to comment #14)
> (In reply to comment #13)
> > Created an attachment (id=25341) [details] [details]
> > test using antcall
> > 
> > I'm afraid the antcall layer isn't enough to cause problems - the attached
> > build file still works for me.
> 
> Sorry for the delay!
> I will require your email id ...will not be possible to send you the build but
> will try to reproduce something similar.

For the 1.8.0, I get this at the end...after I put a debug to the build:

C:\work\subscriptions\cvssubscriptions\esc\source\java\build\build.xml:1709: Una
ble to rename old file (C:\work\subscriptions\cvssubscriptions\esc\source\java\b
uildpackage\buildtemp\eartemp\ICECommon-ejbs.jar) to temporary file
        at org.apache.tools.ant.taskdefs.Zip.renameFile(Zip.java:757)
        at org.apache.tools.ant.taskdefs.Zip.executeMain(Zip.java:636)
        at org.apache.tools.ant.taskdefs.Zip.execute(Zip.java:568)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
        at net.sf.antcontrib.logic.IfTask.execute(IfTask.java:217)
        at sun.reflect.GeneratedMethodAccessor71.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
        at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:154)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1360)
        at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(Single
CheckExecutor.java:38)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1212)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441)
        at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)

        at sun.reflect.GeneratedMethodAccessor72.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
        at net.sf.antcontrib.logic.ForEach.executeSequential(ForEach.java:178)
        at net.sf.antcontrib.logic.ForEach.execute(ForEach.java:254)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1360)
        at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(Single
CheckExecutor.java:38)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1212)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441)
        at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)

        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1360)
        at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(Single
CheckExecutor.java:38)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1212)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441)
        at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)

        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1360)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1329)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
cutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1212)
        at org.apache.tools.ant.Main.runBuild(Main.java:801)
        at org.apache.tools.ant.Main.startAnt(Main.java:218)
        at org.apache.tools.ant.Main.start(Main.java:180)
        at org.apache.tools.ant.Main.main(Main.java:269)
Comment 16 Arockia 2011-07-22 18:46:06 UTC
This is happening for me in 64-Bit Java, Windows 7 and 1.8.2 ANT environment, When I tried it with 32-Bit Java it worked fine
Comment 17 Antoine Levy-Lambert 2013-03-18 02:32:30 UTC
can you provide a build file allowing to reproduce the problem ?