• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic