remm        2004/11/11 16:48:41

  Modified:    catalina/src/share/org/apache/catalina/startup
                        HostConfig.java
  Log:
  - Fix an issue reported on tomcat-user. When a war includes a 
/META-INF/context.xml, the autodeployer doesn't handle it correctly.
    The cause of the issue is simply that the war and expanded folders were not 
properly registered.
  
  Revision  Changes    Path
  1.49      +41 -20    
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.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- HostConfig.java   5 Oct 2004 17:12:49 -0000       1.48
  +++ HostConfig.java   12 Nov 2004 00:48:41 -0000      1.49
  @@ -588,29 +588,35 @@
                   }
               }
               host.addChild(context);
  +            // Get paths for WAR and expanded WAR in appBase
  +            String name = null;
  +            String path = context.getPath();
  +            if (path.equals("")) {
  +                name = "ROOT";
  +            } else {
  +                if (path.startsWith("/")) {
  +                    name = path.substring(1);
  +                } else {
  +                    name = path;
  +                }
  +            }
  +            File expandedDocBase = new File(name);
  +            File warDocBase = new File(name + ".war");
  +            if (!expandedDocBase.isAbsolute()) {
  +                expandedDocBase = new File(appBase(), name);
  +                warDocBase = new File(appBase(), name + ".war");
  +            }
               // Add the eventual unpacked WAR and all the resources which 
will be
               // watched inside it
               if (isWar && unpackWARs) {
  -                String name = null;
  -                String path = context.getPath();
  -                if (path.equals("")) {
  -                    name = "ROOT";
  -                } else {
  -                    if (path.startsWith("/")) {
  -                        name = path.substring(1);
  -                    } else {
  -                        name = path;
  -                    }
  -                }
  -                File docBase = new File(name);
  -                if (!docBase.isAbsolute()) {
  -                    docBase = new File(appBase(), name);
  -                }
  -                deployedApp.redeployResources.put(docBase.getAbsolutePath(),
  -                        new Long(docBase.lastModified()));
  -                addWatchedResources(deployedApp, docBase.getAbsolutePath(), 
context);
  +                
deployedApp.redeployResources.put(expandedDocBase.getAbsolutePath(),
  +                        new Long(expandedDocBase.lastModified()));
  +                addWatchedResources(deployedApp, 
expandedDocBase.getAbsolutePath(), context);
               } else {
                   if (context.getDocBase() != null) {
  +                    // If the context is outside of the Host appBase, 
removing the xml
  +                    // should remove the webapp
  +                    boolean external = false;
                       File docBase = new File(context.getDocBase());
                       if (!docBase.isAbsolute()) {
                           docBase = new File(appBase(), context.getDocBase());
  @@ -618,6 +624,7 @@
                       try {
                           docBase = docBase.getCanonicalFile();
                           if 
(!docBase.getAbsolutePath().startsWith(appBase().getAbsolutePath())) {
  +                            external = true;
                               deployedApp.redeployResources.put
                                   (contextXml.getAbsolutePath(), new 
Long(contextXml.lastModified()));
                               
deployedApp.reloadResources.remove(contextXml.getAbsolutePath());
  @@ -625,8 +632,22 @@
                       } catch (IOException e) {
                           // Ignore
                       }
  +                    if (!external) {
  +                        // Find an existing matching war and expanded folder
  +                        if (warDocBase.exists()) {
  +                            
deployedApp.redeployResources.put(warDocBase.getAbsolutePath(),
  +                                    new Long(warDocBase.lastModified()));
  +                        }
  +                        if (expandedDocBase.exists()) {
  +                            
deployedApp.redeployResources.put(expandedDocBase.getAbsolutePath(),
  +                                    new 
Long(expandedDocBase.lastModified()));
  +                            addWatchedResources(deployedApp, 
  +                                    expandedDocBase.getAbsolutePath(), 
context);
  +                        }
  +                    }
  +                } else {
  +                    addWatchedResources(deployedApp, null, context);
                   }
  -                addWatchedResources(deployedApp, null, context);
               }
           } catch (Throwable t) {
               log.error(sm.getString("hostConfig.deployDescriptor.error",
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to