users@glassfish.java.net

Local Session Bean Lookup

From: Jason Lee <lee_at_iecokc.com>
Date: Mon, 12 Jun 2006 17:33:25 -0500

I'm having trouble grabbing a reference to a local session bean
interface from a web app deployed to the app server as the session bean
(thus the local reference). The session bean has this interface:

@Local
public interface ITestSession {
        void start() throws Exception;
}

If I mark that as @Remote, I can get the remote reference from an out of
container client just fine using the class name as the JNDI lookup. I
mark it as @Local, however, and try to look it up like this from my web
app:

        Context ctx = new InitialContext();
        Object bean = ctx.lookup("com.iecokc.test.ITestSession"); //
No cast need

Which gets me "javax.naming.NameNotFoundException:
com.iecokc.test.ITestSession not found". (For what it's worth,
ITestSession is not in the web apps classpath, and I plan to be working
against "bean" via reflection, so I won't explicitly reference the
interface's class name.) If I try "java:comp/env/ejb/ITestSession" as
the JNDI name as one (possibly old) reference I found, I get
"javax.naming.NameNotFoundException: No object bound to name
java:comp/env/ejb/ITestSession". What's the proper way to lookup the
reference? Or is Glassfish smart enough to treat it as a local call
even if I were to mark it as @Remote? I have the EJB3 spec PDFs in
front of me, but I'm not seeing anything on the subject. Any hints,
pointers, etc?

I appreciate it!
 
--
Jason Lee
Programmer/Analyst