users@glassfish.java.net

JNDI lookup fails for ejb tier vs. web tier

From: <glassfish_at_javadesktop.org>
Date: Wed, 18 Jun 2008 08:47:24 PDT

To avoid Serialization of args to my Session EJBs, my application should only access their Local interfaces. I accomplished this by placing these tags in the web.xml for each bean:

<ejb-local-ref>
<ejb-ref-name>AgencyAccessMgrBean</ejb-ref-name>
<local>com.cfms.data.agency.AgencyAccessMgrLocal</local>
<ejb-link>AgencyAccessMgrBean</ejb-link>
</ejb-local-ref>

And, annotated each Session bean as:

@Stateless(name="AgencyAccessMgrBean")

The POJO I use to access the bean does the following lookup:

AgencyAccessMgrLocal bean = new InitialContext().lookup("java:comp/env/AgencyAccessMgrBean");

This works great for the web tier for any of my beans, but the ejb tier fails the lookup. So, if the web tier invokes Session bean AgencyAccessMgrBean.modify() and this modify() method needs to access another Session bean called UserMgrBean using the same style of POJO lookup it will fail indicating JNDI name "UserMgrBean" not found. Guess I was hoping the web.xml defs were exposed automatically to the ejb tier :(

How do I expose the same JNDI naming in the ejb tier as I have in the web tier so that a lookup from within a Session method will resolve to the correct Local interface? Since the lookup is from within a POJO, I can NOT annotate the POJO.

I only have a persistence.xml in the ejb module deployment, NO ejb-jar.xml or sun-ejb-jar.xml. Ideally, I copy/paste the web.xml sub-section ejb-local-ref rigtht into the ejb-jar.xml and I'm done, but I don't see that syntax available.

If someone could provide the xml syntax using the data above and which xml file to place it in that would be what I need to solve this.

I need this to work the same in each tier so that the same POJO can be used for the lookups using the same JNDI names (ie the same lookup snippet above should work in both web and ejb tiers).

Thanks,
J
[Message sent by forum member 'jameshr' (jameshr)]

http://forums.java.net/jive/thread.jspa?messageID=281063