I created a folder called "webapps-war" within the Tomcat installation directory (CATALINA_HOME). The host's default appBase is "webapps" in this directory. What I wanted to do is use the XML Context file deployment method, i.e. put my xml file into conf/catalina/localhost (in my case) and specify the docBase to look for the war in ${catalina.home}/webapps-war/myapp. But just because the name starts with "webapps", it misinterprets the docBase setting and I get in tomcat.log: "A docBase C:\tomcat-5.5.16\webapps-war\myapp inside the host appBase has been specified, and will be ignored" and then my deployment fails. On the other hand, if I name my folder "somethingelse" instead of "webapps-war", it works like a charm. So not a big problem (trivial workaround) but would be nicer if the rule was perfectly implemented. And that would have saved me hours trying to figure out what was wrong in my deployment!... If my investigation is correct, the problem can be traced back to org.apache.catalina.startup.HostConfig and below is my suggested change against the download from SVN done today (17 March). I'm not an expert on the catalina source, so it would need another pair of eyes and some testing before you can say this is the resolution of this problem. The proposed solution is simply to make sure the string comparaisons includes a trailing "/" after the default appBase. Questions on the suggested resolution: I'm not sure in particular if you can use "/" as the directory separator for all platform of if you'd need to use something like System.getProperty("file.separator")? Would there be other places where this applies? Is there a compelling reason why this can't be done like that? DIFF FILE against $Revision: 386336 $ $Date: 2006-03-16 14:13:00 +0000 (Thu, 16 Mar 2006) $ Compare: (<)D:\work-bak\tomcat\container\catalina\src\share\org\apache\catalina\startup\HostConfig.java (45038 bytes) with: (>)D:\work-bak\tomcat\container\catalina\src\share\org\apache\catalina\startup\HostConfig.java.changed (44596 bytes) 592c592 < if (!docBase.getCanonicalPath().startsWith(appBase().getAbsolutePath())) { --- > if (!docBase.getCanonicalPath().startsWith(appBase().getAbsolutePath() + "/")) { 995,996c995,996 < if ((current.getAbsolutePath().startsWith(appBase().getAbsolutePath())) < || (current.getAbsolutePath().startsWith(configBase().getAbsolutePath()))) { --- > if ((current.getAbsolutePath().startsWith(appBase().getAbsolutePath() + "/")) > || (current.getAbsolutePath().startsWith(configBase().getAbsolutePath() + "/"))) { 1035,1036c1035,1036 < if ((current.getAbsolutePath().startsWith(appBase().getAbsolutePath())) < || (current.getAbsolutePath().startsWith(configBase().getAbsolutePath()))) { --- > if ((current.getAbsolutePath().startsWith(appBase().getAbsolutePath() + "/")) > || (current.getAbsolutePath().startsWith(configBase().getAbsolutePath() + "/"))) { 1052,1053c1052,1053 < if ((current.getAbsolutePath().startsWith(appBase().getAbsolutePath())) < || ((current.getAbsolutePath().startsWith(configBase().getAbsolutePath()) --- > if ((current.getAbsolutePath().startsWith(appBase().getAbsolutePath() + "/")) > || ((current.getAbsolutePath().startsWith(configBase().getAbsolutePath() + "/")
This still appears to exist in the trunk as of today's pull. I've got a one-liner that appears to fix it that I'll post soon.
Created attachment 23007 [details] Patch in ContextConfig.java Tacking on a '/' to the end of both path strings helps to ensure full path parentage when performing the substring match.
I've attached a patch that fixes the immediate issue as per the bug report. However, there could easily be cases that this doesn't catch. Please review. Thanks.
I've gone through HostConfig and appended File.separator where required. It needs to be File.separator rather than '/'. I have applied the fix to trunk and have proposed it for 6.0.x and 5.5.x
This has been fixed in 6.0.x and will be included in 6.0.19 onwards.
This has been fixed in 5.5.x and will be included in 5.5.28 onwards.