This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I am currently preparing for the SCEA. In order to prepare myself and help others, I will periodically post questions for discussion. I will post the question and the answer with an explanation separately. I�d like to get feedback on the correctness of my answer/explanation and constructive criticism to make the question better. I�ll take your feedback and update the question/answer and aggregate them into an exam, which I will later share with the group. Byron Estes
Question #1 Changing the �session-type� bean setting in the deployment descriptor can change a session bean from stateful to stateless. What else may need to be changed for a stateful session bean to become a valid stateless session bean? a)ejbPostCreate methods b)ejbCreate methods c)ejbRemove method d)ejbActivate method e)ejbPassivate method
The answer is �B�. If the stateful session bean has ejbCreate methods other than the default/empty ejbCreate() method, those methods would need to be removed. If the stateful session bean did not have a default/empty ejbCreate() method, then one would need to be added. Answer �A� is incorrect because ejbPostCreate() is a callback method for entity beans, not session beans. Answer �C� is incorrect because ejbRemove() can remain unchanged for a stateful or stateless session bean. It is immaterial. Answer �D� is incorrect. While ejbActivate() is only pertinent to a stateful session bean (i.e. which needs to preserve conversational state), leaving the method in the bean class will not result in any validation errors. Answer �E� is incorrect. While ejbPassivate() is only pertinent to a stateful session bean (i.e. which needs to preserve conversational state), leaving the method in the bean class will not result in any validation errors.