This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Session Bean Doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Session Bean Doubt" Watch "Session Bean Doubt" New topic
Author

Session Bean Doubt

Shanmugam Karthikeyan
Ranch Hand

Joined: Aug 02, 2002
Posts: 58
1. Which statements about stateful and stateless session beans are true?
(Choose all that apply.)

a). Only stateful session beans support transactions.
b). Only stateful session beans can be passivated.
c). Only stateful session beans have a 'setSessionContext' method.
d). Both stateful and stateless session beans can support
overloaded 'ejbCreate' methods.
e). Both stateful and stateless session beans can implement
the 'javax.ejb.SessionSynchronization' interface.
f). Both stateful and stateless session beans can have instance variable state.

ans given : b,f - how a stateless session bean can have state in an instance variable.
my answer : b


SCJP 1.4<br />SCWCD 1.4<br />SCBCD 1.3
Ugender Rekulampally
Ranch Hand

Joined: Nov 14, 2005
Posts: 130
Karthikeyan,
answers B and F are correct. session conversational state is different from instance variables state. but in stateless session bean, if you declare any instance variables, becareful in handling them. or you will see unwanted results.

thanks,
Ugender
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
Also see this thread
Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
I am not clear about option b.
stateless session beans can also be passivated but their passivation is not required and in their normal lifecycle their passivation is not required.
**and one more,in all types of beans we have to define ejbPassivate()
Patrick Williams
Ranch Hand

Joined: Apr 03, 2005
Posts: 213
Hi Raj, I'm not sure I agree with you. Although those beans inherit those methods from javax.ejb.SessionBean, they are never called in a stateless session bean. Stateless beans are "awake" as they sit in the instance pool so there is no need to wake them up (ejbActivate())or put them to sleep (ejbPassivate()). Also, they do not keep conversational state so there is no need to use these methods no reload the instance with the related client. If you have HF EJB, pg 223 has the lifecycle diagram for both stateful and stateless session beans.

HTH


Patrick<br /> <br />SCJP/SCWCD/SCBCD/SCDJWS/SCEA<br /> <br />Currently working on:<br />SCJP 6
Balaji Anand
Ranch Hand

Joined: Nov 03, 2004
Posts: 146
I agree that the answers are b and f.
Raj, the stateless session bean never get a call to passivate and activate. they are there in the SessionBean just because there is only one common interface be it stateful or stateless.
Stateless session bean never gets passivated
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session Bean Doubt