Unable to delete file that are no longer on project classpath [message #530139] |
Wed, 28 April 2010 11:57  |
Eclipse User |
|
|
|
Hi,
I'm trying to remove a jar from the classpath of a project and to delete the jar resource.
Unfortunately, most of the time (and not always!!), on the deletion an exception is thrown:
If the project is not shared on svn:
Contains: Could not delete '\monpath\vers\le\jar\monjar.jar'.
org.eclipse.core.runtime.CoreException: Problems encountered while deleting files.
at org.eclipse.core.internal.filesystem.local.LocalFile.delete(LocalFile.java:124)
at org.eclipse.core.internal.resources.ResourceTree.internalDeleteFile(ResourceTree.java:303)
at org.eclipse.core.internal.resources.ResourceTree.standardDeleteFile(ResourceTree.java:780)
at org.eclipse.core.internal.resources.Resource.unprotectedDelete(Resource.java:1764)
at org.eclipse.core.internal.resources.Resource.delete(Resource.java:724)
at org.eclipse.core.internal.resources.Resource.delete(Resource.java:690)
if the project is shared on svn:
org.eclipse.team.svn.core.connector.SVNConnectorException: svn: Cannot delete file 'F:\monpath\vers\le\jar\monjar.jarr'
at org.polarion.team.svn.connector.svnkit.SVNKitConnector.handleClientException(SVNKitConnector.java:1384)
at org.polarion.team.svn.connector.svnkit.SVNKitConnector.remove(SVNKitConnector.java:1178)
at org.eclipse.team.svn.core.extension.factory.ThreadNameModifier.remove(ThreadNameModifier.java:488)
at org.eclipse.team.svn.core.operation.local.refactor.DeleteResourceOperation.runImpl(DeleteResourceOperation.java:102)
at org.eclipse.team.svn.core.operation.AbstractActionOperation.run(AbstractActionOperation.java:77)
at org.eclipse.team.svn.core.utility.ProgressMonitorUtility.doTask(ProgressMonitorUtility.java:104)
at org.eclipse.team.svn.core.operation.CompositeOperation.runImpl(CompositeOperation.java:94)
at org.eclipse.team.svn.core.operation.AbstractActionOperation.run(AbstractActionOperation.java:77)
at org.eclipse.team.svn.core.operation.LoggedOperation.run(LoggedOperation.java:38)
at org.eclipse.team.svn.core.utility.ProgressMonitorUtility.doTask(ProgressMonitorUtility.java:104)
at org.eclipse.team.svn.core.utility.ProgressMonitorUtility.doTaskExternal(ProgressMonitorUtility.java:90)
at org.eclipse.team.svn.core.utility.ProgressMonitorUtility.doTaskExternal(ProgressMonitorUtility.java:81)
at org.eclipse.team.svn.core.SVNTeamMoveDeleteHook.doDelete(SVNTeamMoveDeleteHook.java:134)
at org.eclipse.team.svn.core.SVNTeamMoveDeleteHook.deleteFile(SVNTeamMoveDeleteHook.java:52)
at org.eclipse.team.internal.core.MoveDeleteManager.deleteFile(MoveDeleteManager.java:50)
at org.eclipse.core.internal.resources.Resource.unprotectedDelete(Resource.java:1763)
at org.eclipse.core.internal.resources.Resource.delete(Resource.java:724)
at org.eclipse.core.internal.resources.Resource.delete(Resource.java:690)
I check with "unlocker" that the file is not locked.
I am doing the deletion after removing the file from the classpath:
getJavaProject().setRawClasspath(newClasspathEntries, true, new NullProgressMonitor());
getIFileOfTheJar().delete(true, new NullProgressMonitor());
Between the two instruction, I tried this (and to combined them):
- refresh the project
refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
- call the make consistent method
getJavaProject().makeConsistent(new NullProgressMonitor());
But I encounter the same error.
Thanks by advance for any hint
Regards
|
|
|
Re: Unable to delete file that are no longer on project classpath [message #530462 is a reply to message #530139] |
Thu, 29 April 2010 12:45   |
Eclipse User |
|
|
|
"Aurelien Pupier" <aurelien.pupier@bonitasoft.com> wrote in message
news:hr9ltf$7l0$1@build.eclipse.org...
> Hi,
>
> I'm trying to remove a jar from the classpath of a project and to delete
> the jar resource.
>
> Unfortunately, most of the time (and not always!!), on the deletion an
> exception is thrown:
This is on Windows, I'm guessing? This has been an ongoing problem for many
years. It seems that on Windows, files do not get unlocked until some
undeterministic amount of time after the file handle has been closed. The
problem is particularly bad for jars if the jar has been opened by a
classloader - I can't tell from your example whether that is the case.
> [...]
>
> I check with "unlocker" that the file is not locked.
Are you checking before or after you try the delete? It's quite possible
that it gets unlocked in between deleting and checking.
> I am doing the deletion after removing the file from the classpath:
>
> getJavaProject().setRawClasspath(newClasspathEntries, true, new
> NullProgressMonitor());
> getIFileOfTheJar().delete(true, new NullProgressMonitor());
>
>
> Between the two instruction, I tried this (and to combined them):
> - refresh the project
> refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
> - call the make consistent method
> getJavaProject().makeConsistent(new NullProgressMonitor());
>
> But I encounter the same error.
>
> Thanks by advance for any hint
You can try catching the exception and retrying a few times, possibly with a
sleep() in between; and if this is an option for you, you can try making the
file deleteOnExit, so that it gets deleted when the VM shuts down. Which
*sometimes* works.
|
|
|
Re: Unable to delete file that are no longer on project classpath [message #530468 is a reply to message #530462] |
Thu, 29 April 2010 13:39  |
Eclipse User |
|
|
|
First, thanks for your response.
yes it is on windows
yes sometimes it was opened by a classloader but not always.
A first implementation of that was that I delete jars that are no longer on the classpath on the next startup. But now I want to commit the modification when it is done and another issue is that I can't replace the file.
BTW I never encountered this issue directly in Eclipse using the Configure build path preference page and deleting the file after.
So I'm wondering if there is a trick to force the deletion.
Regards
|
|
|
Powered by
FUDForum. Page generated in 0.03706 seconds