0
votes

1

I am getting below error when I am looking up a JNDI connection for jdbc datasource:

javax.naming.ConfigurationException: 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. [Root exception is javax.naming.NameNotFoundException: Name not found in context "java:".]

On server startup, I have created a servlet init method using which I am starting my thread pool of rabbit MQ queues listener threads. Whenever there is some message in the queue, I have to process that message and insert it into the database. When trying to use the existing code of inserting into the database getting the above JNDI exception in WebSphere server. Any pointers will help.

1

1 Answers

0
votes

Unmanaged threads like yours (threads spawned from an application) are outside of the appserver's control and do not have access to managed Java EE context information, therefore JNDI operations on "java:" names are not supported. Instead of creating your own thread pool, use the appserver's. To provide you more info on how to do so, I'd need to know whether you're using WebSphere traditional or Liberty.