Bug 16877 - Null pointer exception when misspelling attribute name in server.xml <Context>.
Summary: Null pointer exception when misspelling attribute name in server.xml <Context>.
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 4
Classification: Unclassified
Component: Catalina:Modules (show other bugs)
Version: 4.1.18
Hardware: All other
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-07 12:57 UTC by Thomas Eliasson
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments
Null check has been introduced for Context.path & Context.docBase - Fix in ContextRuleSet.java (1.49 KB, patch)
2003-07-07 11:34 UTC, Anil Bhatia
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.