Which statement is true about both stateful session beans and stateless session beans?
A.
Bean instance are NOT required to survive container crashes.
B.
Any bean instance must be able to handle concurrent invocations from different threads.
C.
A bean with bean-managed transactions must commit or roll back any transaction before
returning from a business method.
D.
The container passivates and actives them using methods annotated with @PrePassivate and
@PostActivate annotations.
Explanation:
Note:
*Session beans can either be stateful or stateless. With stateful beans, the EJB container saves
internal bean data during and in between method calls on the clients behalf. With stateless beans,
the clients may call any available instance of an instantiated bean for as long as the EJB container
has the ability to pool stateless beans. This enables the number of instantiations of a bean to be
reduced, thereby reducing required resources.Incorrect:
B:Stateful session beans maintain state both within and between transactions. Each stateful
session bean is therefore associated with a specific client.
D:@PrePassivate(javax.ejb.PrePassivate) :
If a stateful session bean instance is idle for too long, the container might passivate it and store its
state to a cache.
The method tagged by this annotation is called before the container passivates the bean instance.
This annotation is only applicable to stateful session beans.
Only A.
C is not true for stateful.
JRS138 Enterprise JavaBeans 3.1, Final Release: 13.3.3 Enterprise Beans Using Bean-Managed Transaction Demarcation
A stateful session bean instance may, but is not required to, commit a started transaction before a business method returns.
A