diff -Naur jboss-3.2.6-src-old/server/src/main/org/jboss/web/AbstractWebContainer.java jboss-3.2.6-src-new/server/src/main/org/jboss/web/AbstractWebContainer.java --- jboss-3.2.6-src-old/server/src/main/org/jboss/web/AbstractWebContainer.java 2004-08-07 00:46:52.000000000 -0300 +++ jboss-3.2.6-src-new/server/src/main/org/jboss/web/AbstractWebContainer.java 2004-11-11 11:13:01.661641500 -0200 @@ -247,8 +247,9 @@ if( warFile.isDirectory() == false && unpackWars == true ) { File tmp = new File(warFile.getAbsolutePath()+".tmp"); - if( warFile.renameTo(tmp) == false ) - throw new DeploymentException("Was unable to move war to: "+tmp); + if( rename(warFile, tmp) == false ) { + throw new DeploymentException("Was unable to move file: "+warFile); + } if( warFile.mkdir() == false ) throw new DeploymentException("Was unable to mkdir: "+warFile); log.debug("Unpacking war to: "+warFile); @@ -702,4 +703,31 @@ urlSet.add(url.toExternalForm()); } } + + private boolean rename(File fromFile, File toFile) { + // (wcasante@cpqd.com.br) + // Sun JVM Bug Parade (ID 4042592) workaround + // if rename fails, sleep and try, and try... + + if (fromFile.renameTo(toFile) == false) { + // can be any problem with closed resources... + System.gc(); + + for (int tries = 10; tries > 0; tries--) { + try { + // sleep some time + Thread.sleep(10); + } catch (InterruptedException ex) {} + + // keep trying! + if (fromFile.renameTo(toFile)) { + return true; + } + } + return false; + } + + // first try was ok + return true; + } }