On WebSphere, JNDI lookup fails during CDI container bootstrap

203 Views Asked by At

On WebSphere 9, I'm trying to do a JNDI lookup from a CDI extension and I get this error:

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...

So, there is application code (inside an EAR) executed by a server-managed thread, on a JavaEE component lifecycle callback but there is no bounded JNDI context.

I've played with com.ibm.ws.cdi.immediate.ejb.start system property to see if this helps but I had no luck.

Has anyone encountered this problem? Is there any solution?

1

There are 1 best solutions below

1
On

Unfortunately JNDI lookups cannot be performed inside a CDI extension as Websphere triggers the observers in CDI extensions before the JNDI namespace is configured.

Sorry to be the bearer of bad news.