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

Moderator: admin

Post Reply
Guest

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

Post by Guest »

Why does YLocal yl = (YLocal) sctx.lookup("XYSessionBean") not work? Is it because the bean implements 2 interfaces?

admin
Site Admin
Posts: 8909
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

prakashyaji
Posts: 25
Joined: Sun May 13, 2012 1:39 am
Contact:

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

Post 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

admin
Site Admin
Posts: 8909
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

gurpreet_asrgndu
Posts: 55
Joined: Thu Jan 03, 2013 7:51 am
Contact:

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

Post by gurpreet_asrgndu »

YLocal yl = (YLocal) sctx.getBusinessObject(YLocal.class); do we have to always put cast operator ? or is it optional ?

admin
Site Admin
Posts: 8909
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

It's optional.
If you like our products and services, please help us by posting your review here.

n4noman
Posts: 4
Joined: Thu Apr 09, 2015 8:44 am
Contact:

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

Post by n4noman »

How can a bean declare 2 local interfaces?

admin
Site Admin
Posts: 8909
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

By using the implements clause - ... implements I1 , I2.
If you like our products and services, please help us by posting your review here.

n4noman
Posts: 4
Joined: Thu Apr 09, 2015 8:44 am
Contact:

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

Post 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?

admin
Site Admin
Posts: 8909
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

Yes, it is possible.
If you like our products and services, please help us by posting your review here.

negociadordns
Posts: 2
Joined: Tue Mar 04, 2014 7:03 pm
Contact:

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

Post 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

peter.varga
Posts: 5
Joined: Wed Dec 16, 2015 3:16 am
Contact:

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

Post 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?

peter.varga
Posts: 5
Joined: Wed Dec 16, 2015 3:16 am
Contact:

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

Post by peter.varga »

Please, someone answer my question!

admin
Site Admin
Posts: 8909
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

admin
Site Admin
Posts: 8909
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest