From 859a4212b5c4ee3ebe50a26e52bfa86368b32207 Mon Sep 17 00:00:00 2001 From: pero Date: Sun, 20 Jan 2008 14:01:52 +0000 Subject: [PATCH] FIX: WatchedResource does not work if app is outside "webapps" git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@613558 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/catalina/startup/HostConfig.java | 19 ++++++++++++++----- webapps/docs/changelog.xml | 3 +++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/java/org/apache/catalina/startup/HostConfig.java b/java/org/apache/catalina/startup/HostConfig.java index dbdf82e0e..29e9f0527 100644 --- a/java/org/apache/catalina/startup/HostConfig.java +++ b/java/org/apache/catalina/startup/HostConfig.java @@ -636,11 +636,15 @@ public class HostConfig 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"); + // default to appBase dir + name + File expandedDocBase = new File(appBase(), name); + if (context.getDocBase() != null) { + // first assume docBase is absolute + expandedDocBase = new File(context.getDocBase()); + if (!expandedDocBase.isAbsolute()) { + // if docBase specified and relative, it must be relative to appBase + expandedDocBase = new File(appBase(), context.getDocBase()); + } } // Add the eventual unpacked WAR and all the resources which will be // watched inside it @@ -652,6 +656,7 @@ public class HostConfig addWatchedResources(deployedApp, expandedDocBase.getAbsolutePath(), context); } else { // Find an existing matching war and expanded folder + File warDocBase = new File(expandedDocBase.getAbsolutePath() + ".war"); if (warDocBase.exists()) { deployedApp.redeployResources.put(warDocBase.getAbsolutePath(), new Long(warDocBase.lastModified())); @@ -966,9 +971,13 @@ public class HostConfig if (docBase != null) { resource = new File(docBaseFile, watchedResources[i]); } else { + if(log.isDebugEnabled()) + log.debug("Ignoring non-existent WatchedResource '" + resource.getAbsolutePath() + "'"); continue; } } + if(log.isDebugEnabled()) + log.debug("Watching WatchedResource '" + resource.getAbsolutePath() + "'"); app.reloadResources.put(resource.getAbsolutePath(), new Long(resource.lastModified())); } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 80b12456a..d325186be 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -46,6 +46,9 @@ + 38131: WatchedResource does not work if app is outside host appbase webapps. + Patch provided by Gernot Pfingstl (pero) + 44261: Fix "Restricted listeners property file not found" message fix. Patch provided by David Jencks. (pero) -- 2.11.0