Bug 16877

Summary: Null pointer exception when misspelling attribute name in server.xml <Context>.
Product: Tomcat 4 Reporter: Thomas Eliasson <thomas.eliasson>
Component: Catalina:ModulesAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 4.1.18   
Target Milestone: ---   
Hardware: All   
OS: other   
Attachments: Null check has been introduced for Context.path & Context.docBase - Fix in ContextRuleSet.java

Description Thomas Eliasson 2003-02-07 12:57:47 UTC
If you write 'path' e.g. as 'Path'  in Context in server.xml.
I.e. 
<Context Path="/appname" ...
instead of
<Context path="/appname" ...
You'll get a null pointer exception instead of a nice message stating that path
is missing.
Stacktrace:
java.lang.NullPointerException
        at java.util.Hashtable.put(Hashtable.java:375)
        at
org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:3336)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:3472)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:738)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347)
        at org.apache.catalina.core.StandardService.start(StandardService.java:497)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:2189)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:512)
        at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
        at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
        at java.lang.reflect.Method.invoke(Native Method)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
Comment 1 Anil Bhatia 2003-07-07 11:34:11 UTC
Created attachment 7120 [details]
Null check has been introduced for Context.path & Context.docBase - Fix in ContextRuleSet.java
Comment 2 Anil Bhatia 2003-07-07 11:48:09 UTC
The above attached fix addresses the situation when path or docBase have not 
been specified for Context. 

To have a generic fix, such attributes could be made #REQUIRED in the schema 
for this xml doc and calling setValidating(true) for the digester.
Comment 3 Mark Thomas 2004-05-08 13:51:38 UTC
Thanks for the patch. I have committed a slightly modified version to TC4.

Your genric solution is not one that is available to us as there is no DTD or 
schema for server.xml. The reason for this is that server.xml is designed to 
be extensible (eg custom valves) and it is impossible to define in advance the 
attributes that any such custom component may require.