Bug 38154 - NPE when accessing default context "/" after it is stopped
NPE when accessing default context "/" after it is stopped
Status: RESOLVED FIXED
Product: Tomcat 5
Classification: Unclassified
Component: Catalina
5.5.12
PC Windows 2000
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2006-01-06 01:47 UTC by Jamie Maher
Modified: 2006-04-13 11:45 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jamie Maher 2006-01-06 01:47:14 UTC
If the default application "/" is stopped then is subsequently accessed via a
webbrowser the following NPE occurs. However, if a seperate user-installed
application is installed and then stopped it results in an error report
indicating: HTTP Status 503 - This application is not currently available.

In the code in the Mapper for the rule 4c - welcome resources processing:

--snip--
try {
  file = context.resources.lookup(pathStr);
} catch(NamingException nex) {
  // Swallow not found, since this is normal
}
--snip--

It will catch a naming exception and continue on, but not a NPE..


--------------------------------------------------------------------------
SEVERE: An exception or error occurred in the container during the request
processing
java.lang.NullPointerException
	at java.lang.String.startsWith(Unknown Source)
	at java.lang.String.startsWith(Unknown Source)
	at org.apache.naming.resources.FileDirContext.file(FileDirContext.java:841)
	at
org.apache.naming.resources.FileDirContext.getAttributes(FileDirContext.java:432)
	at
org.apache.naming.resources.BaseDirContext.getAttributes(BaseDirContext.java:724)
	at org.apache.naming.resources.ProxyDirContext.cacheLoad(ProxyDirContext.java:1525)
	at
org.apache.naming.resources.ProxyDirContext.cacheLookup(ProxyDirContext.java:1448)
	at org.apache.naming.resources.ProxyDirContext.lookup(ProxyDirContext.java:282)
	at org.apache.tomcat.util.http.mapper.Mapper.internalMapWrapper(Mapper.java:732)
	at org.apache.tomcat.util.http.mapper.Mapper.internalMap(Mapper.java:622)
	at org.apache.tomcat.util.http.mapper.Mapper.map(Mapper.java:512)
	at
org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:272)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:146)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
	at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
	at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
	at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
	at java.lang.Thread.run(Unknown Source)
Comment 1 Jamie Maher 2006-01-06 01:54:35 UTC
This will only happen if no resource is entered.

Eg. Accessing "http://localhost/" or "http://localhost" will cause the NPE error

But, accessing "http://localhost/test.html" will cause it to correctly return a
HTTP Status 503 - This application is not currently available response.
Comment 2 Yoav Shapira 2006-04-13 18:45:54 UTC
The NPE occurs becasue FileDirContext#release sets absoluteBase to null. 
absoluteBase is the argument to the String#startsWith call on line 841.  I've
added a check for that case to avoid the immediate NPE.  Thanks for reporting it.