Skip to Content
0
Former Member
Sep 04, 2013 at 04:57 AM

JNDI Context lookup issues between EJB and Servlet and others

185 Views

Hi,

I am noticing the following behavior with respect to JNDI Lookups:

The contexts are not shared between EJBs and Servelts.

If I add a object into JNDI in a servlet, it is not looked up in EJB and vice versa.

On particular threads, like the Omni Socket threads - both the JNDI context is emtpy, and does not have access to either objects set via EJB or Servlet.

I am not sure, if this is a standard J2EE application server behavior, and I did not see such behavior in JBOSS atleast.

Could you let me know :

1. If this is expected behavior or a bug?

2. If bug : What would be the workaround, if expected : What is the expected way to look up objects in each others context?

P.S:

I am getting the initial context, by just doing a "new InitialContext()"

Demo Project (Attached jndi.txt : rename to jndi.rar)

http://server/jndi/JNDITest

This will print the jndi tree

Notice that I add an object "guru" into the initial context in a servlet and this is not visible in the EJB.

I am not able to notice the thread differences here, but in certain cases that happens too.

Thanks

Guru

Attachments

jndi.txt.zip (9.4 kB)