Summary: | Context parameters are being overridden with parameters from the web application deployment descriptor | ||
---|---|---|---|
Product: | Tomcat 6 | Reporter: | Sergey <dx_xb> |
Component: | Catalina | Assignee: | Tomcat Developers Mailing List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | chris, n.beekman, oliver, wg |
Priority: | P2 | ||
Version: | 6.0.30 | ||
Target Milestone: | default | ||
Hardware: | PC | ||
OS: | All |
Description
Sergey
2011-02-01 13:04:17 UTC
I can reproduce the problem (Tomcat 6.0.30 on JDK6u23, Windows XP, 32bit, *.zip distribution). can reproduce using apache-tomcat-7.0.8-windows-x86.zip, jdk1.6.0_23, windows 7 Sergey's explanation is good, but just in case any more detail is required in how to reproduce it, here's the steps I take. Expand a tomcat distribution. Edit the <tomcat_home>\webapps\root\WEB-INF\web.xml file to become <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <display-name>Welcome to Tomcat</display-name> <description> Welcome to Tomcat </description> <context-param> <param-name>initialDbPath</param-name> <param-value>a</param-value> </context-param> </web-app> then edit <tomcat_home>\conf\context.xml to become <Context> <Parameter name="initialDbPath" value="xyz" override="false"/> </Context> then add a new file <tomcat_home>\webapps\ROOT\test.jsp which contains <%@ page contentType="text/html; charset=UTF-8" %> <html> <body> <br>initialDbPath is : ${initParam.initialDbPath} </body> </html> The context.xml setting should override the web.xml setting, but this is not happening This has been fixed in 7.0.x and will be included in 7.0.9 onwards. The Tomcat 7 patch has been proposed for backport to 6.0.x. Some comments on the fix for this issue (r1070609), for better understanding: 1) This bug was caused by the fix for bug 49987 (r1022117), Tomcat 6.0.30-32 are affected. 2) The cause of this, which went unnoticed when the patch for Bug 49987 was reviewed, is that ApplicationContext#setInitParameter(name, value) is effective only once. Subsequent calls to #setInitParameter(name, value) with the same name are ignored. That is why init-param overriding with override="false" stopped working. Fixed in 6.0.x and will be included in 6.0.33 onwards. |