InitialContext in a servlet or JSP, threads created by the servlet or JSP fail with a noThreadContext message and a nullPointerException.
 Technote (troubleshooting)
 
Problem(Abstract)
A servlet or JSP can get an InitialContext and perform a lookup, but a thread created by the servlet or JSP receives a nullPointerException and noThreadContext message.

A lookup performed in a thread created by the servlet or jsp will receive a NameNotFoundException.
 
Cause
When a servlet or JSP (in the same JVM) performs a lookup of the EJB using the resource reference, the request is successful. The failure only occurs when a background thread in the same JVM performs the lookup.
There are actually two problems. The second one is minor.
1. The naming code calls the container to get the java URL name space for the JNDI call, and it does not expect a null return value. So, that's where the null pointer exception came from.

But, the real problem came before that,

2. When the container could not find a Java URL name space for the thread.

 
Resolving the problem
Do not execute the lookup in a separate thread, because there is no way to "give" a spun-off thread any context. Modify the code so that it does not perform a java: lookup or attempt to get an InitialContext in a thread spun-off by a servlet or JSP.
 
 
Cross Reference information
Segment Product Component Platform Version Edition
Application Servers Runtimes for Java Technology Java SDK
 
 


Document Information


Product categories: Software > Application Servers > Distributed Application & Web Servers > WebSphere Application Server > JNDI/Naming
Operating system(s): Windows
Software version: 5.0
Software edition:
Reference #: 1175742
IBM Group: Software Group
Modified date: Aug 1, 2004