remm 2005/02/15 07:42:58 Modified: catalina/src/share/org/apache/catalina/startup HostConfig.java LocalStrings.properties catalina/src/conf context.xml Log: - Tentative fix for 33572: context.xml should be a redeploy resource. This is done by prioritizing the redeploy resources. - I need to test this better. The basic cases seem to be working (editing manager.xml, as well as an expanded folder as per the bug report). - Remove context.xml from the list of watched resources. Revision Changes Path 1.55 +36 -23 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/HostConfig.java Index: HostConfig.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/HostConfig.java,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- HostConfig.java 29 Jan 2005 19:45:55 -0000 1.54 +++ HostConfig.java 15 Feb 2005 15:42:58 -0000 1.55 @@ -25,6 +25,7 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.jar.JarEntry; import java.util.jar.JarFile; @@ -572,9 +573,6 @@ } context.setConfigFile(contextXml.getAbsolutePath()); context.setPath(contextPath); - // Add the context XML to the list of watched files - deployedApp.reloadResources.put - (contextXml.getAbsolutePath(), new Long(contextXml.lastModified())); // Add the associated docBase to the redeployed list if it's a WAR boolean isWar = false; if (context.getDocBase() != null) { @@ -628,7 +626,6 @@ external = true; deployedApp.redeployResources.put (contextXml.getAbsolutePath(), new Long(contextXml.lastModified())); - deployedApp.reloadResources.remove(contextXml.getAbsolutePath()); } } catch (IOException e) { // Ignore @@ -645,8 +642,14 @@ addWatchedResources(deployedApp, expandedDocBase.getAbsolutePath(), context); } + // Add the context XML to the list of files which should trigger a redeployment + deployedApp.redeployResources.put + (contextXml.getAbsolutePath(), new Long(contextXml.lastModified())); } } else { + // Add the context XML to the list of files which should trigger a redeployment + deployedApp.redeployResources.put + (contextXml.getAbsolutePath(), new Long(contextXml.lastModified())); addWatchedResources(deployedApp, null, context); } } @@ -904,13 +907,17 @@ } context.setPath(contextPath); context.setDocBase(file); + File configFile = new File(dir, Constants.ApplicationContextXml); if (deployXML) { - context.setConfigFile - ((new File(dir, Constants.ApplicationContextXml)).getAbsolutePath()); + context.setConfigFile(configFile.getAbsolutePath()); } host.addChild(context); deployedApp.redeployResources.put(dir.getAbsolutePath(), new Long(dir.lastModified())); + if (deployXML) { + deployedApp.redeployResources.put(configFile.getAbsolutePath(), + new Long(configFile.lastModified())); + } addWatchedResources(deployedApp, dir.getAbsolutePath(), context); } catch (Throwable t) { log.error(sm.getString("hostConfig.deployDir.error", file), t); @@ -974,7 +981,9 @@ if (resource.exists()) { long lastModified = ((Long) app.redeployResources.get(resources[i])).longValue(); if ((!resource.isDirectory()) && resource.lastModified() > lastModified) { - // Redeploy application + // Undeploy application + if (log.isInfoEnabled()) + log.info(sm.getString("hostConfig.undeploy", app.name)); ContainerBase context = (ContainerBase) host.findChild(app.name); host.removeChild(context); try { @@ -984,28 +993,32 @@ ("hostConfig.context.destroy", app.name), e); } // Delete other redeploy resources - for (int j = 0; j < resources.length; j++) { - if (j != i) { - try { - File current = new File(resources[j]); - current = current.getCanonicalFile(); - if ((current.getAbsolutePath().startsWith(appBase().getAbsolutePath())) + for (int j = i + 1; j < resources.length; j++) { + try { + File current = new File(resources[j]); + current = current.getCanonicalFile(); + if ((current.getAbsolutePath().startsWith(appBase().getAbsolutePath())) || (current.getAbsolutePath().startsWith(configBase().getAbsolutePath()))) { - if (log.isDebugEnabled()) - log.debug("Delete " + current); - ExpandWar.delete(current); - } - } catch (IOException e) { - log.warn(sm.getString - ("hostConfig.canonicalizing", app.name), e); + if (log.isDebugEnabled()) + log.debug("Delete " + current); + ExpandWar.delete(current); } + } catch (IOException e) { + log.warn(sm.getString + ("hostConfig.canonicalizing", app.name), e); } } deployed.remove(app.name); return; } } else { + long lastModified = ((Long) app.redeployResources.get(resources[i])).longValue(); + if (lastModified == 0L) { + continue; + } // Undeploy application + if (log.isInfoEnabled()) + log.info(sm.getString("hostConfig.undeploy", app.name)); ContainerBase context = (ContainerBase) host.findChild(app.name); host.removeChild(context); try { @@ -1015,7 +1028,7 @@ ("hostConfig.context.destroy", app.name), e); } // Delete all redeploy resources - for (int j = 0; j < resources.length; j++) { + for (int j = i + 1; j < resources.length; j++) { try { File current = new File(resources[j]); current = current.getCanonicalFile(); @@ -1277,7 +1290,7 @@ * contain resources like the context.xml file, a compressed WAR path. * The value is the last modification time. */ - public HashMap redeployResources = new HashMap(); + public LinkedHashMap redeployResources = new LinkedHashMap(); /** * Any modification of the specified (static) resources will cause a 1.14 +1 -1 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/LocalStrings.properties Index: LocalStrings.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/LocalStrings.properties,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- LocalStrings.properties 14 Feb 2005 19:27:41 -0000 1.13 +++ LocalStrings.properties 15 Feb 2005 15:42:58 -0000 1.14 @@ -64,7 +64,7 @@ hostConfig.removeWAR=War {0} is undeployed hostConfig.start=HostConfig: Processing START hostConfig.stop=HostConfig: Processing STOP -hostConfig.undeploy=Undeploying web application at context path {0} +hostConfig.undeploy=Undeploying context [{0}] hostConfig.undeploy.error=Error undeploying web application at context path {0} hostConfig.undeploying=Undeploying deployed web applications userConfig.database=Exception loading user database 1.3 +6 -7 jakarta-tomcat-catalina/catalina/src/conf/context.xml Index: context.xml =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/conf/context.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- context.xml 1 Sep 2004 22:53:25 -0000 1.2 +++ context.xml 15 Feb 2005 15:42:58 -0000 1.3 @@ -2,12 +2,11 @@ <Context> <!-- Default set of monitored resources --> - <WatchedResource>WEB-INF/web.xml</WatchedResource> - <WatchedResource>META-INF/context.xml</WatchedResource> - - <!-- Uncomment this to disable session persistence across Tomcat restarts --> - <!-- - <Manager pathname="" /> - --> + <WatchedResource>WEB-INF/web.xml</WatchedResource> + <!-- Uncomment this to disable session persistence across Tomcat restarts --> + <!-- + <Manager pathname="" /> + --> + </Context> \ No newline at end of file
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]