ejb@glassfish.java.net

Re: local slsb lookup

From: Dies Koper <diesk_at_fast.au.fujitsu.com>
Date: Sun, 24 May 2009 16:37:54 +1000

Hi Tim,

Assuming you are using EJB3.0 (because I haven't read the EJB3.1 spec
yet, I don't know if anything changed), you need to add the following
annotation to the Java EE component class that your POJO is being called
from (for example your Servlet class or other EJB class):

@EJB(name = "MyLocalEJB", beanInterface = MyLocal.class)

In the POJO, you'd then do the lookup as you described in #
A:

> InitialContext ic =new InitialContext();
> ic.lookup("java:comp/env/MyLocalEJB");

Regards,
Dies


Tim Kiener wrote:
>
> hi there,
>
> its really annoying. i just cant get this usecase to work:
>
> #1: i have got a simple POJO
> #2: i have got a
>
> @Local(MyLocal.class)
> @Stateless
> public class MyLocalEJB implements MyLocal{...}
>
> #3 the PJO and the EJB run within the same EJB-Jar(and EAR)
>
> Question:
>
> How can i lookup the local EJB within my POJO.
>
>
> I tried the following:
>
> #A
>
> InitialContext ic =new InitialContext();
> ic.loopkup("java:comp/env/MyLocalEJB");
>
>
> #B
> setting @Stateless(name="MyLocalEJB")
>
> and tried the ic.lookup(...) again
>
>
> #C
> setting @Stateless(name="ejb/MyLocalEJB")
>
> and tried the ic.lookup("java:comp/env/ejb/MyLocalEJB") again
>
>
>
> CONCLUSION
> nothing worked.
>
> the glassfish-faq is not clear for me. they assume that you want to
> lookup a local-ejb from a web-client and therefore
> edit the web.xml
> thats not what i want.
>
> if anybody knows the solution, please be as clear as you can writing
> sample-code.
>
>
>
> thanks in advance. and sorry for sounding stressed.
> tim
>