I'm working on a project that consists of a "web" project that contains my struts presentation layer, and a utility "business" project that contains my business layer. I'm just using pojos (no EJBs). Both these projects are part of the same EAR file.
My test server has a websphere datasource setup, and I have a resource reference named jdbc/tmDB defined in the web deployment descriptor for the "web" project.
Anything in my web project can access the datasource. Anything in my business project can access the datasource as well. However if an object in my business project is run as a thread and I try to access the datasource I get the following logged on the console...
[1/30/06 10:32:55:397 EST] 41dbc872 ConnectionFac I J2CA0122I: Resource reference jdbc/tmDB could not be located, so default values of the following are used: [Resource-ref settings]
Q: In WebSphere Application Server Version Version 5.0, is it possible to do a JNDI lookup in a thread spawned by a servlet?
A: This is currently not supported. According to the Servlet 2.3 specification, servlet containers that are part of a J2EE-compliant implementation are not currently required to support lookups of JNDI registered objects when performed on threads created by the developer.
Hi Todd, I'm facing the same problem (like many others as I see searching on Google)... Have you found an alternative approach to get resources referenced in the container from a thread spawned by a servlet? I thought about RMI access to an object which exports information about the environment obtained from the servlet container, (e.g. a DataSource), but I'm trying to avoid RMI because of extra compile work...
Andrea Colleoni PlaneCom s.r.l. [ May 02, 2006: Message edited by: Andrea Colleoni ]