users@glassfish.java.net

Re: Container Question

From: Sahoo <Sahoo_at_Sun.COM>
Date: Tue, 16 Oct 2007 09:02:49 +0530

Chapter #5 of the Java EE 5 platform spec is a great place to learn
about resource injection, lookup, etc. Any way, here is what you need to do:
Step 1: Add a <ejb-reference> or <ejb-local-reference> entry in web.xml
depending on the type of EJB you are accessing . As part of
ejb-reference or ejb-local-reference, you have to give a name (say
ejb/LogicalName) to your EJB reference. That's called a logical name.
You can use that name in your code without worrying about what is the
actual name of the target EJB.

Step 2: Now your look up code looks something like this:
MyEJBInterfaceType ejb = (MyEJBInterfaceType) new
InitialContext().lookup("java:comp/env").lookup("ejb/LogicalName");

Step 3: Before you deploy your application, you should bind the EJB
reference to an actual EJB. That can be achieved by using ejb-link
element if the target EJB is part of the same ear file, or using
<ejb-link> element in sun-web.xml.

Thanks,
Sahoo

glassfish_at_javadesktop.org wrote:
> How would I go about doing a JNDI (?) lookup (a reference site would be sufficient), I've only started developing web apps really hardcore since JEE5, so I've never had the experience.
> [Message sent by forum member 'amattas' (amattas)]
>
> http://forums.java.net/jive/thread.jspa?messageID=240269
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>