Community
Participate
Working Groups
when I start jetty7,I can copy war to webapps folder,but I can not delete it. i think there is some file handler not close.I write a test java file, the result is that i can not delete AJspWar.war. ------------------------------------------------------- import java.io.File; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.resource.JarResource; import org.eclipse.jetty.util.resource.Resource; public class TestDeleteFile { public static void main(String[] args) throws Exception{ String war = "d:\\test\\AJspWar.war"; Resource res = Resource.newResource(war); res = JarResource.newJarResource(res); Resource web_inf= res.addPath("WEB-INF/"); File extractedWebInfDir= new File("d:\\test\\webinf"); if (extractedWebInfDir.exists()) IO.delete(extractedWebInfDir); extractedWebInfDir.mkdir(); Resource web_inf_lib = web_inf.addPath("lib/"); File webInfDir=new File(extractedWebInfDir,"WEB-INF"); webInfDir.mkdir(); if (web_inf_lib.exists()) { File webInfLibDir = new File(webInfDir, "lib"); if (webInfLibDir.exists()) IO.delete(webInfLibDir); webInfLibDir.mkdir(); Log.info("Copying WEB-INF/lib " + web_inf_lib + " to " + webInfLibDir); web_inf_lib.copyTo(webInfLibDir); } Resource web_inf_classes = web_inf.addPath("classes/"); if (web_inf_classes.exists()) { File webInfClassesDir = new File(webInfDir, "classes"); if (webInfClassesDir.exists()) IO.delete(webInfClassesDir); webInfClassesDir.mkdir(); Log.info("Copying WEB-INF/classes from "+web_inf_classes+" to "+webInfClassesDir.getAbsolutePath()); web_inf_classes.copyTo(webInfClassesDir); } web_inf=Resource.newResource(extractedWebInfDir.getCanonicalPath()); File warFile = new File(war); if(warFile.delete()){ System.out.println("delete success"); }else{ System.out.println("delete failure"); } } }
in this example missing a few of Resource.release(); before execute delete. Also after relesing them same problem, but I think it's NORMAL that in a application server you can't delete ear/war. You can update it (and will be redeployed automatically), already try and works.
looks like your using windows which is always a problem with java files and deletes, just a mess anyway, typically if your looking to manage that sort of lifecycle with a webapp I would recommend you use the context deployment mechanism where you have descriptors in the contexts directory that point to a war file, but I just tested this out on my linux box it it works both ways, removing the context file and having the app undeploy, and removing the war file and having the app undeploy. I suspect the context approach might work for you on windows, give it a shot and if it doesn't reopen the issue and we'll see about looking at the windows issue that or its simply this issue: http://docs.codehaus.org/display/JETTY/Files+locked+on+Windows