Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Qn about exceptions from ejbcertificate

 
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.
 
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 ]
 
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??
 
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.
 
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
 
I have gone to look for myself. If I should return before I get back, keep me here with 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
    Bookmark Topic Watch Topic
  • New Topic