Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Kathy need your help -> Sharpen Your Pencil pg:547

 
sanneel paul
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all
Can anybody tell me the answer of Sharpen Your Pencil pg:547.
Thanx in advance

-Sanneel
[ November 03, 2005: Message edited by: sanneel paul ]
 
Agasthya Iyer
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sanneel,

Scenarios

i. You catch a checked exception in your ejbActivate method. The method is not in a transaction. (A. Throw an EJBException). Becuase the ejbActivate is a container callback method we cannot throw a checked exception from a method that does not declare the exception. The only thing we should throw from one of the container callbacks of SessionBean is an EJBException

ii. A DivideByZero exception occurs as your business logic is running. You do not have a try/catch for this. (D. Allow the exception to propagate(in other words, duck it).

iii. You throw a CreateException from your ejbCreate() method and you realize that you probably cannot safely complete your transaction (C. Invoke setRollbackOnly()

iv. You catch a checked exception in a business method, and realize that your bean is probably corrupt (C. Invoke setRollbackOnly())

HTH

Best Regards,
Agasthya Iyer
 
B.Sathish
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a better suggestion for iv :

Throw a wrapped EJBException to the container. Because your bean is corrupt. Apart from rolling back the transaction, you would want the container to kill your corrupt bean. If you just call setRollbackOnly, the container will rollback the transaction, but the corrupt bean would continue processing business logic. So, let your bean throw a wrapped EJBException to the container so that the container can rollback the transaction and kill the corrupt bean and log the exception
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic