Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Qn about exceptions from ejbcertificate

 
nachagoni rishi
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which one of the following statements regarding the client view of exceptions received from an enterprise bean invocation is correct?



1. The client can safely continue the transaction by retrying the operation if an application exception is received.



2. The client can safely continue the transaction by retrying the operation if an application exception is received, but only after checking the transaction has not been marked for rollback.



3. The client can safely continue the transaction by retrying the operation if a non-application exception is received.



4. A local client cannot continue a transaction if javax.transaction.TransactionRolledbackLocalException is received.



5. A remote client cannot continue a transaction if javax.transaction.TransactionRolledbackException is received.


correct answer is 5.

why is option 4 wrong.
 
Serkan Yazici
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by nachagoni rishi:

4. A local client cannot continue a transaction if javax.transaction.TransactionRolledbackLocalException is received.

why is option 4 wrong.


Because the correct name of this exception is javax.ejb.TransactionRolledbackLocalException
[ November 19, 2004: Message edited by: Serkan Yazici ]
 
jyothi ve
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why not option 1 correct?

According the spec 18.3.1 and from the Table 15

Client View: if Client Received App Exception, can attempt to continue computation in the transaction, and eventually commit the transaction.

From the spec I fee option 1 also correct.


Correct me if I am wrong??
 
Sandesh Tathare
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jyothi,

IMO, option 2 is correct against 1:
2. The client can safely continue the transaction by retrying the operation if an application exception is received, but only after checking the transaction has not been marked for rollback.


Option 1 says: The client can safely continue the transaction by retrying the operation if an application exception is received. But if EJBContext.setRollbackOnly() has been called before throwing application exception, even if client continues transaction it will not commit. So it's a good idea for a client program to check whether transaction has been marked for rollback and then safely continue.

Note: A lot depends on how one interprets word safely here. If we say safely means without any exception, yes then option 1 also makes sense. But while answering above question I interpreted safely means that it's safe to continue transaction and probability of transaction being rollback is less.

Please correct me if I am wrong.
 
Mark Lybarger
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm on board with jyothi on this one. seems like 1 is correct to me.

if a bean throws an application exception the transaction _may_ be doomed, but the client can't tell. the client can either contine processing (even retry the same operation ).
 
Serkan Yazici
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mark Lybarger:
i'm on board with jyothi on this one. seems like 1 is correct to me.

if a bean throws an application exception the transaction _may_ be doomed, but the client can't tell. the client can either contine processing (even retry the same operation ).


If a transaction started by the client, client can check if the transaction was marked for rollback or not the same way as BMT beans (using the UserTransaction.getStatus method). So if safely phrase means knowing that the transaction can definetely be committed, then option (2) would be more correct.

However, IMO this is a very ambigiously worded question and I wouldn't lose too much sleep over it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic