Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 331036

Summary: Exception for resources
Product: [Tools] AJDT Reporter: Andrew Clement <aclement>
Component: CoreAssignee: AJDT-inbox <AJDT-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: andrew.eisenberg
Version: 2.1.2   
Target Milestone: 2.1.1   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Andrew Clement CLA 2010-11-24 10:58:19 EST
Reported to me this morning, a few files are having the same 'resource already exists on disk' problem, a stack trace for one of them is:

org.eclipse.core.internal.resources.ResourceException: Resource already exists on disk: '/org.eclipse.virgo.kernel.deployer.dm/target/classes/META-INF/spring/deployer-dm-context.xml'.
at org.eclipse.core.internal.localstore.FileSystemResourceManager.copy(FileSystemResourceManager.java:224)
at org.eclipse.core.internal.resources.Resource.copy(Resource.java:548)
at org.eclipse.core.internal.resources.Resource.copy(Resource.java:526)
at org.eclipse.ajdt.core.builder.AJBuilder$1.visit(AJBuilder.java:776)
at org.eclipse.core.internal.resources.Resource$2.visit(Resource.java:112)
at org.eclipse.core.internal.resources.Resource$1.visitElement(Resource.java:64)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:82)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:86)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:86)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:86)
at org.eclipse.core.internal.watson.ElementTreeIterator.iterate(ElementTreeIterator.java:127)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:74)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:110)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:94)
at org.eclipse.ajdt.core.builder.AJBuilder.copyResources(AJBuilder.java:791)
at org.eclipse.ajdt.core.builder.AJBuilder.build(AJBuilder.java:217)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:629)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:172)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:203)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:255)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:258)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:311)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:343)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:242)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 1 Andrew Eisenberg CLA 2010-11-24 12:02:45 EST
My guess is that what is happening here is that there is a build occurring outside of Eclipse that is placing the resources on the disk.  But, there is no refresh occurring inside of Eclipse, so the AJBuilder assumes that there is no file at the specified location, when there actually is.  

The solution seems to be to do a resource refresh on the target before trying to copy.  However, a resource refresh is a non-trivial action, so I'd like to avoid doing them if I don't have to.  But, it seems like this will be necessary.
Comment 2 Andrew Eisenberg CLA 2010-11-24 12:04:13 EST
I guess another possibility would be to do the copy inside of a try statement, and in the catch block, look for the specific resource exception.  If so, then we can just swallow the exception, if it is a different exception, then we rethrow.
Comment 3 Andrew Eisenberg CLA 2010-11-24 13:06:56 EST
The solution that I have now is to log the exception to the AJDT Event trace, but to otherwise ignore it.  I will be committing shortly when some tests are passing.
Comment 4 Andrew Eisenberg CLA 2010-11-24 16:33:28 EST
Fix committed.