Setup: in a project on windows with an ear / war / jar in an exploded format and having started the server in debug mode. If you make any changes to a file in the jar, the jar will be rebuilt and try to be deployed. This seems to work but it pops up an error dialog box every time. The error message looks like the following:
Error renaming C:\devtools\jboss\jboss-4.2.3.GA\server\default\tmp\jbosstoolsTemp\tmp2587902707203199490.jar to C:\devtools\jboss\jboss-4.2.3.GA\server\default\deploy\MyExampleEAR.ear\MyExampleWAR.war\WEB-INF\lib\MyDependantJar-2.3-SNAPSHOT.jar. This may be caused by your server's temporary deploy directory being on a different filesystem than the final destination. You may adjust these settings in the server editor.
For the method org.jboss.ide.eclipse.as.core.server.xpl.PublishCopyUtil#safeRename(File,File,int) it calls File#renameTo(File) for moving the file from the temp directory to WEB-INF/lib. From the javadocs for renameTo it says that this might not work if the file in the destination already exists.
Possible fixes:
- before calling the rename, try to delete on the destination file ( to.delete() )
- org.apache.commons.io.FileUtils#moveFile(File,File) tries to call the renameTo and if that fails it falls back to coping the file to the destination.
Sample Unit test
/* This test needs to be run on windows. */ @Test public void testCopyForWindows() throws IOException { File from = File.createTempFile("source", ".txt"); File to = File.createTempFile("target", ".txt"); File[] files = {from, to}; for (File file : files) { // set for cleanup file.deleteOnExit(); assertTrue("file should exist" + file.getAbsolutePath(), file.exists()); assertTrue("file should be writable" + file.getAbsolutePath(), file.canWrite()); } // if safeRename was not private! assertTrue("should have been able to rename the file", safeRename(from, to, 10)); }