• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

this question has been posted mant time, but...

 
Timber Lee
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
following question has been posted in this forum, butI can not understand the sentance "The bean cannot recover from this checked exception", does it mean the exception has been handled by container? if so, the container rolls transaction back and throws an EJBException, that is to say no given options are proper for this question. do you think so?
EJB business method performs an operation that
throws a checked exception. The bean cannot recover from this checked exception and should rollback. The bean will be deployed using
container-managed transaction demarcation. Which
implementation is the BEST?
A. public void businessMethod() { try { // operation
throwing
SomeCheckedException goes here }
catch (SomeCheckedException ae) { throw new
EJBException(ae); } }
B. public void businessMethod() { try { // operation
throwing
SomeCheckedException goes here }
catch (SomeCheckedException ae) {
context.setRollbackOnly(); throw
new EJBException(ae); } }
C. public void businessMethod() throws EJBException
{ try { //
operation throwing
SomeCheckedException goes here } catch
(SomeCheckedException ae) {
throw new EJBException(ae); }
}
D. public void businessMethod() throws EJBException
{ try { //
operation throwing
SomeCheckedException goes here } catch
(SomeCheckedException ae) {
context.setRollbackOnly();
throw new EJBException(ae); } } }}
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Timber Lee:
I can not understand the sentance "The bean cannot recover from this checked exception"

This basically means the EJB does not have the necessary information to properly handle this error condition. Obviously, something has to take place, however we know that the situation can not be "corrected" in our EJB. The question is asking, in this type of situation, what should the EJB do?
[ March 27, 2003: Message edited by: Chris Mathews ]
 
Timber Lee
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my answer is "D", is it correct?
[ March 27, 2003: Message edited by: Timber Lee ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic