Page 1 of 1

Re: About Question enthuware.oce-ejbd.v6.2.376 :

Posted: Sat Aug 06, 2011 6:23 pm
by Guest
Why does YLocal yl = (YLocal) sctx.lookup("XYSessionBean") not work? Is it because the bean implements 2 interfaces?

Re: About Question enthuware.oce-ejbd.v6.2.376 :

Posted: Sun Aug 07, 2011 9:05 am
by admin
This is not valid because -
1. No-interface view is provided only if the bean class does not provide any other view. Or if it provide other views, it also contains @LocalBean annotation. Therefore, the bean code given in the question does not provide a no-interface view.
2. Even if the no-interface view were available in this bean, the name used here to look it up is not right. It should follow rules given in Section 4.4.
3. When interacting with a reference to the no-interface view, the client must not make any assumptions regarding the internal implementation of the reference, such as any instance-specific state that may be present in the reference. Thus, it would not be appropriate to assume that the looked up bean implements YLocal.

Re: About Question enthuware.oce-ejbd.v6.2.376 :

Posted: Mon May 14, 2012 5:11 pm
by prakashyaji
In the explanation you specify as follows
//Does not work
//YLocal yl = (YLocal) sctx.lookup("java:comp/env/ejb/XYSessionBean");

Can you please explain me why this won't work? Is it because the Bean name is not specified or something?

Thanks,
Prakash Yaji

Re: About Question enthuware.oce-ejbd.v6.2.376 :

Posted: Wed May 16, 2012 8:33 pm
by admin
Because the java:comp space contains the objects that are injected into the component (either using annotation or deployment descriptor). Here, we are not injecting any reference.

HTH,
Paul.

Re: About Question enthuware.oce-ejbd.v6.2.376 :

Posted: Tue Jul 16, 2013 4:12 pm
by gurpreet_asrgndu
YLocal yl = (YLocal) sctx.getBusinessObject(YLocal.class); do we have to always put cast operator ? or is it optional ?

Re: About Question enthuware.oce-ejbd.v6.2.376 :

Posted: Tue Jul 16, 2013 6:19 pm
by admin
It's optional.

Re: About Question enthuware.oce-ejbd.v6.2.376 :

Posted: Thu Apr 09, 2015 12:21 pm
by n4noman
How can a bean declare 2 local interfaces?

Re: About Question enthuware.oce-ejbd.v6.2.376 :

Posted: Thu Apr 09, 2015 8:28 pm
by admin
By using the implements clause - ... implements I1 , I2.

Re: About Question enthuware.oce-ejbd.v6.2.376 :

Posted: Fri Apr 10, 2015 3:07 am
by n4noman
I was talking about this specific question, where it says:

Code: Select all

@Stateful @Local({XLocal.class, YLocal.class}) 
public class XYSessionBean implements XLocal, YLocal {
Is it allowed to declare more than one interface via @Local or @Remote annotation?

Re: About Question enthuware.oce-ejbd.v6.2.376 :

Posted: Fri Apr 10, 2015 5:03 am
by admin
Yes, it is possible.

Re: About Question enthuware.oce-ejbd.v6.2.376 :

Posted: Mon May 04, 2015 10:54 am
by negociadordns
The case of the bean name in the first answer is incorrect.

(YLocal) sctx.lookup("java:global/EJBD-ToyApp/EJBD-ToyApp-ejb/XYSessionbean!YLocal");

Please change XYSessionbean to XYSessionBean, so the answer would be 100% correct.


Regards

Re: About Question enthuware.oce-ejbd.v6.2.376 :

Posted: Sun Mar 18, 2018 4:23 pm
by peter.varga
"YLocal yl = (YLocal) sctx.lookup("YLocal");"
I suppose this option is not correct because of the name String. What String would be correct?

Re: About Question enthuware.oce-ejbd.v6.2.376 :

Posted: Sun Apr 08, 2018 2:38 pm
by peter.varga
Please, someone answer my question!

Re: About Question enthuware.oce-ejbd.v6.2.376 :

Posted: Sun Apr 08, 2018 9:58 pm
by admin
Yes, the name is incorrect. The correct string is already given in option 1: "java:global/EJBD-ToyApp/EJBD-ToyApp-ejb/XYSessionbean!YLocal"
You should also go through section 4.4 of Global JNDI Access of EJB 3.1 for complete details.

HTH,
Paul.

Re: About Question enthuware.oce-ejbd.v6.2.376 :

Posted: Sun Apr 08, 2018 10:05 pm
by admin
negociadordns wrote:The case of the bean name in the first answer is incorrect.

(YLocal) sctx.lookup("java:global/EJBD-ToyApp/EJBD-ToyApp-ejb/XYSessionbean!YLocal");

Please change XYSessionbean to XYSessionBean, so the answer would be 100% correct.


Regards
Fixed.
thank you for your feedback!
Paul.