You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2003/07/23 13:55:28 UTC
DO NOT REPLY [Bug 21822] -
Placing a Valve inside a Context gives Null Pointer Exception...
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21822>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21822
Placing a Valve inside a Context gives Null Pointer Exception...
------- Additional Comments From banil@novell.com 2003-07-23 11:55 -------
Analysis of the problem:
In ValveBase::createObjectName line 292, host is expected to have a non-null
value. This will happen only if parent has been set for the current Context
that has a Valve definition.
This call can be traced back to org.apache.catalina.core.ContainerBase.addValve
(ContainerBase.java:1306), which can be further traced back to
org.apache.commons.digester.SetNextRule.end(SetNextRule.java:256).
If we look at ContextRuleSet::addRuleInstances, (line 248) statement:
digester.addObjectCreate(prefix + "Context/Valve",
null, // MUST be specified in the element
"className");
is setting the corresponding Rule whose later execution (*end*) leads to NPE.
Another statement in same method (line 164):
digester.addSetNext(prefix + "Context",
"addChild",
"org.apache.catalina.Container");
is responsible for correctly setting the parent-child relationship between Host
and the current Context. But before the *end* of this Rule can be called, the
*end* of the previous Rule gets called leading to NPE.
Hence, if we decide to retain the statement (line 291)
Host host = (Host) container.getParent();
in ValveBase::createObjectName, then we should make sure that this call would
return a non-null Host reference.
One of the ways to achieve this is the following modification:
--------------------------------------------------------------------
--- Tomcat5.0.4\jakarta-tomcat-
catalina\catalina\src\share\org\apache\catalina\startup\SetDocBaseRule.java
Mon Jul 14 20:54:26 2003
+++ Modified\Tomcat5.0.4\jakarta-tomcat-
catalina\catalina\src\share\org\apache\catalina\startup\SetDocBaseRule.java
Wed Jul 23 17:13:10 2003
@@ -127,6 +127,8 @@
}
String appBase = host.getAppBase();
+ child.setParent(host);
+
if (!(host instanceof StandardHost)) {
return;
}
---------------------------------------------------------------------
An additional call to child.setParent(host) in *begin* will make sure that
later call to getParent() returns a non-null Host reference.
Of course, there could be other ways to fix this problem.
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org