IBM Support

Spawning a new thread from a J2EE application thread to do a jndi lookup is not supported

Troubleshooting


Problem

Performing a JNDI lookup on a database connection on a thread other than the IBM WebSphere Application Server thread (For example: a WebContainer thread) is not supported.

Cause

A spawned thread does not inherit the J2EE context. It is not possible to do an indirect JNDI lookup (that is, a lookup using a java:comp/env reference), since the resource references are part of the J2EE context. It is possible to perform a direct lookup using the spawned thread. But it is not technically supported according to the J2EE specification.

Resolving The Problem

Using a Java™ call such as "newThread()" to spawn a new thread is not supported according to the J2EE specification. This spawned thread does not inherit the J2EE context. What is recommended to do instead is to use an asynchronous bean or Commonj WorkManager thread. These threads have a proper J2EE context and support an indirect JNDI lookup.

[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"EJB Container","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF012","label":"IBM i"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"9.0;8.5.5;8.0;7.0","Edition":"Base;Network Deployment","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SSNVBF","label":"Runtimes for Java Technology"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Java SDK","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB36","label":"IBM Automation"}}]

Historical Number

60940;344;000

Document Information

Modified date:
15 June 2018

UID

swg21246676