users@glassfish.java.net

an EJB2.1 stateless session bean with remote and local interface -- how?

From: <glassfish_at_javadesktop.org>
Date: Wed, 09 Jan 2008 19:06:44 PST

[b]Hi All

FYI - I'm new to GlassFish, so I apologize if my question sounds silly...

I have requirement to define a stateless session bean that can be looked up using either a remote or local interface (EJB2.1).

It seems that if I create a local interface - only - I have no issues with the JNDI lookup...e.g., [/b]


        try {
            Context c = new InitialContext();
            DddEJBLocalHome rv = (DddEJBLocalHome) c.lookup("java:comp/env/DddEJBBean");
            return rv.create();
        } catch (NamingException ne) {
            java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        } catch (CreateException ce) {
            java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE, "exception caught", ce);
            throw new RuntimeException(ce);
        }


[b]The problem I have is when I add a remote interface.

That is when I create a stateless session bean with both a remote and local interface, the local interface JNDI lookup no longer works.

I get the following error when doing the same lookup:[/b]

-
-
-
Caused by: javax.naming.NameNotFoundException: No object bound to name java:comp/env/DddEJBBean
        at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:834)
        at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:173)
        at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:337)
        at javax.naming.InitialContext.lookup(InitialContext.java:351)
        at ddd.ejb.Helper.lookupDddEJBBean(Helper.java:29)
        ... 56 more



[b]I'm somewhat confused by this, because deploying similar to Websphere and JBoss causes no issues.

QUESTION: How to I properly create a stateless session bean (EJB2.1) in GlassFish and what does the JNDI lookup code look like?... ejb-jar.xml?...

I've attached the code (minus jars) in case this will be helpful in understanding.

Thanks for any help!!!

sd[/b]
[Message sent by forum member 'sairndain' (sairndain)]

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