ejb@glassfish.java.net

Re: local slsb lookup

From: Kenneth Saks <Kenneth.Saks_at_Sun.COM>
Date: Tue, 26 May 2009 14:21:19 -0400

On May 26, 2009, at 1:20 PM, Tim Kiener wrote:

> hi ken,
> thanks for your answer.
>
> so in other words:
> there is no way to lookup a local ejb-cmp from a real, standalone
> POJO, which is not used by a managed component, right?

Right. In EJB 3.0 it's all based on ejb-local-ref or @EJB.

> tim
>
>
> Am 26.05.2009 um 17:34 schrieb Kenneth Saks:
>
>>
>> On May 24, 2009, at 4:27 PM, Tim Kiener wrote:
>>
>>> dies, thanks for your message.
>>> my POJO is not called from an EJB3-component or servlet or
>>> antyhing else managed by the container.
>>> it will called from a spring-component and the spring-component
>>> from an external jcr-event(like a continous polling on the
>>> filesystem).
>>> so no managed-component is involved until the lookup.
>>>
>>>
>>> a local-ejb3-component can be looked up by any POJO within the
>>> same classloader.
>>
>> Hi Tim,
>>
>> The EJB 3.0 spec doesn't define a portable global lookup mechanism
>> for Local EJB components. Some vendors have implemented that
>> feature but it's not portable. We're addressing this issue in the
>> EJB 3.1 spec. See http://blogs.sun.com/kensaks/entry/portable_global_jndi_names
>>
>> --ken
>>
>>
>>> apparently glassfish does not provide this.
>>> jboss does, though.
>>>
>>>
>>> tim
>>>
>>>
>>> Am 24.05.2009 um 08:37 schrieb Dies Koper:
>>>
>>>> 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
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net
>>>> For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net
>>> For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net
>