users@glassfish.java.net

Accessing EJBs from a POJO

From: <glassfish_at_javadesktop.org>
Date: Thu, 29 Jan 2009 14:56:29 PST

Hi,

I followed the instructions on this page https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#POJOLocalEJB but have so far been unsuccessful in getting a true POJO to be able to lookup an ejb through the jndi. I've tried the @EJB annotation as well as the <ejb-local-ref> in the web.xml file and it's a no go either way. Can anyone tell me if there is something I'm missing?

Thanks,

Drew


@EJB(name="test",beanInterface=FormularyManagerLocal.class)
public class EntityListener
{

        @PostLoad
        public void postLoad(FormularyUser user)
        {
                InitialContext ctx;
                try
                {
                        ctx = new InitialContext();
                        Object obj = ctx.lookup("java:comp/env/test"); //$NON-NLS-1$
                        assert obj != null;
                }
                catch (NamingException e1)
                {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                }
        }
}
[Message sent by forum member 'utdrew' (utdrew)]

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