Bug 24588

Summary: NullPointerException from ProxyDirContext
Product: Tomcat 4 Reporter: Daniel Sheppard <daniels>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED WONTFIX    
Severity: normal    
Priority: P3    
Version: 4.1.29   
Target Milestone: ---   
Hardware: Other   
OS: AIX   

Description Daniel Sheppard 2003-11-10 23:15:35 UTC
I'm trying to imagine ways in which my code could be causing this and coming up
blank.

java.lang.NullPointerException
	at
org.apache.naming.resources.ProxyDirContext.cacheLoad(ProxyDirContext.java(Compiled
Code))
	at
org.apache.naming.resources.ProxyDirContext.cacheLookup(ProxyDirContext.java(Compiled
Code))
	at
org.apache.naming.resources.ProxyDirContext.lookup(ProxyDirContext.java(Compiled
Code))
	at
org.apache.catalina.loader.WebappClassLoader.findResourceInternal(WebappClassLoader.java(Compiled
Code))
	at
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java(Compiled
Code))
	at
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java(Compiled
Code))
	at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java(Compiled
Code))
	at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java(Compiled
Code))
	at
com.pronto.presentation.action.order.SearchOrdersAction.getParameters(SearchOrdersAction.java:58)
	at
com.pronto.presentation.action.order.SearchOrdersAction.execute(SearchOrdersAction.java:44)
	at com.pronto.presentation.EProntoController.doGet(EProntoController.java:62)

line 58 of SearchOrdersAction.java is:
SearchOrderParameters params = new SearchOrderParameters();

SearchOrderParameters extends from Object, and has the default constructor. It
contains no imports of any classes that I would consider significant. 

The problem was constantly reproducable while the webapp was running, but in a
most infuriating manner, the problem has resolved itself after performing a
stop/start in the manager app. I don't like problems that resolve themselves
without any apparent intervention. 

Looking at the code for ProxyDirContext.cacheLoad, the objects referenced are:

entry - null is checked for in the cacheLookup method, immediately prior to this
method call.

dirContext - the public constructor would throw null if this was null, the
protected constructor would let it through though.

attributes - could dirContext.getAttributes(entry.name) be returning null? My
understanding is that it would throw a NamingException rather than return null.
If it does return null, line 1492 will throw a nullpointer.

object - same situation here. If dirContext.lookup(name) can return null, 1507
throws nullpointer. If the toString() method on that object returns null, 1514
will throw.

is - could entry.resource.streamContent() return null? if so, 1530 throws.


None of those stand out as likely suspects to me.
Comment 1 Mark Thomas 2004-06-21 22:39:36 UTC
Were you ever able to repeat this or was it a one off?
Comment 2 Daniel Sheppard 2004-06-21 23:53:30 UTC
It was a one-off occurence
Comment 3 Mark Thomas 2004-06-22 19:56:16 UTC
Without a repeatable test case this is going to be very difficult / impossible 
to track down. Since it was a one off, I am going to resolve this bug as a 
WONTFIX.
Comment 4 Curtis Rutledge 2004-11-17 18:08:58 UTC
I've recently ran into this bug. 
Restarting tomcat causes the problem to go away for a while. 
I've included a stacktrace with line numbers:
Currently my solution is to increase the amount of memory the VM has available 
with the -Xmx -Xms options.
I'm tempted to look at the source now to see what is really going on.

Caused by: java.lang.NullPointerException
	at org.apache.naming.resources.ProxyDirContext.cacheLoad
(ProxyDirContext.java:1534)
	at org.apache.naming.resources.ProxyDirContext.cacheLookup
(ProxyDirContext.java:1412)
	at org.apache.naming.resources.ProxyDirContext.lookup
(ProxyDirContext.java:300)
	at org.apache.catalina.loader.WebappClassLoader.findResourceInternal
(WebappClassLoader.java:1730)
	at org.apache.catalina.loader.WebappClassLoader.findClassInternal
(WebappClassLoader.java:1619)
	at org.apache.catalina.loader.WebappClassLoader.findClass
(WebappClassLoader.java:968)
	at org.apache.catalina.loader.WebappClassLoader.loadClass
(WebappClassLoader.java:1409)
	at org.apache.catalina.loader.WebappClassLoader.loadClass
(WebappClassLoader.java:1289)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
(My code that doesn't explicitly refer ClassLoader or Class)



Comment 5 Curtis Rutledge 2004-11-18 17:23:36 UTC
Got the source for the tomcat server we are running. 4.1.24.
The line that is causing the problem is 

int n = is.read(b, pos, length - pos);

Since it is a NullPointerException I would assume that the inputstream is null 
for whatever reason.