Bug 36840 - NullPointerException processing Realm in Context
NullPointerException processing Realm in Context
Status: RESOLVED FIXED
Product: Tomcat 5
Classification: Unclassified
Component: Catalina
5.5.9
Other other
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2005-09-28 12:14 UTC by David Goodenough
Modified: 2005-10-16 00:49 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Goodenough 2005-09-28 12:14:45 UTC
I have put a file in $CATALINA_HOME/conf/Catalina/localhost for application 
context.  It reads:- 
 
<Context>  
  <Realm classname="org.apache.catalina.realm.JDBCRealm" debug="99"  
         driverName="org.postgresql.Driver" 
         connectionURL="jdbc:postgresql:authority" connectionName="david"  
         userTable="users" userNameCol="user_name" userCredCol="user_pass" 
         userRoleTable="roles" roleNameCol="role_name"> 
    </Realm>  
  </Context> 
 
When I try to start Tomcat 5.5.9 (I tried 5.5.12 a well, same result) I get a 
NullPointerException in Digester, the stack trace from which starts:- 
 
26-Sep-2005 19:20:26 org.apache.tomcat.util.digester.Digester startElement 
SEVERE: Begin event threw exception 
java.lang.NullPointerException 
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:261) 
	at java.lang.ClassLoader.loadClass(ClassLoader.java:299) 
	at java.lang.ClassLoader.loadClass(ClassLoader.java:299) 
	at java.lang.ClassLoader.loadClass(ClassLoader.java:251) 
	at 
org.apache.tomcat.util.digester.ObjectCreateRule.begin(ObjectCreateRule.java:204) 
	at org.apache.tomcat.util.digester.Rule.begin(Rule.java:152) 
	at 
org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1275) 
	at 
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:533) 
	at 
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:878) 
	at 
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693) 
	at 
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368) 
	at 
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834) 
	at 
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764) 
	at 
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148) 
	at 
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242) 
	at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1561) 
	at 
org.apache.catalina.startup.ContextConfig.processContextConfig(ContextConfig.java:778) 
	at 
org.apache.catalina.startup.ContextConfig.contextConfig(ContextConfig.java:718) 
	at 
org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:974) 
	at 
org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:273) 
	at 
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) 
	at 
org.apache.catalina.core.StandardContext.init(StandardContext.java:5015) 
	at 
org.apache.catalina.core.StandardContext.start(StandardContext.java:3885) 
 
If I comment out the Realm bit of the Context it does not crash. 
 
Tomcat then complains of an exception processing "the default web.xml", which 
is misleading in the extreem. 
 
I have no idea what it is trying to load, but I know that the Realm class is 
available in a JAR in server/lib and also that the Postgresql driver is in the 
same directory.
Comment 1 william.barker 2005-09-29 08:44:35 UTC
Please go and try the GlassFish project, instead of of wasting real developers 
time with really stupid reports like this.  Believe me, you won't be 
missed  :).

XML parsing is, was, and always will be case-sensitive.  Now actually read the 
FM, and specify your Realm as className="...".
Comment 2 David Goodenough 2005-09-29 10:23:56 UTC
OK, so there was a simple mistake on my part which mis-encoded an attribute, 
that is fine and obviously my fault. 
 
BUT, this should NOT have lead to a NullPointerException, and the error 
messages are totally misleading as they state that the problem is in the 
"default web.xml" when actually it was is the application specific context 
file. 
 
Comment 3 Yoav Shapira 2005-10-16 08:49:21 UTC
The following has been added:

When a web.xml parsing error occurs,
- ContextConfig will report the full web.xml file URL that it was trying to parse
- ContextConfig will report the line number and column number where the error
occured, assuming the SAXParseException contains that information.
- ContextConfig will log the full stack trace (this is already happening)

The following was already available:
- Setting DEBUG-level logging on the ContextConfig class or the catalina startup
package will cause a logging message to be emitted from processContextConfig for
each context with its name/URL.

The following was added:
- Setting DEBUG-level logging on the ContextConfig class or the catalina startup
 package will casue a logging message to be emitted from applicationWebXml
before it starts parsing the web.xml file with its full URL.