users@glassfish.java.net

Re: Accessing EJBs from a POJO

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Thu, 29 Jan 2009 17:39:47 -0800

Drew,

You need to add the @EJB annotation on a component that calls your POJO.

Regards,
-marina

glassfish_at_javadesktop.org wrote:
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>