My requirement is do some background process (saving to DB) when user performs a request.
However, it has to be asynchronous. So I forked a separate thread with in my servlet code, using
java.util.concurrent.ExecutorService interface. The run(...) of this thread, basically does a JNDI lookup
for my session bean to perform the DB operation.
Problem: The lookup is failing with NamingException : java:comp/env not found. The thread executing the look
up is not part of container process.
javaURLContex E NMSV0310E: A JNDI operation on a "java:" name cannot be completed because the server runtime is not able to associate the operation's thread with any J2EE application component. This condition can occur when the JNDI client using the "java:" name is not executed on the thread of a server application request. Make sure that a J2EE application does not execute JNDI operations on "java:" names within static code blocks or in threads created by that J2EE application. Such code does not necessarily run on the thread of a server application request and therefore is not supported by JNDI operations on "java:" names.
How would I make sure that the new thread I spun can be able to lookup resources?