• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question from ejbcertificate.com on Exception

 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All;

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.

From the option given for the above question,I think second option is the correct answer.But in the site option (5) is given as the right answer.According to me if option (5) is correct then option (4) should also be the correct answer.Pls clarify.

Thankx And Regards
Shiv
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll drop a hint why (4) is incorrect: Are you sure that a client can ever receive javax.transaction.TransactionRolledbackLocalException?
 
ShivPrakash Srivastava
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Roger,

According to the Specs, if the bean uses Container Managed Transaction Demarcation with transaction Attribute Mandatory,Supports and Required and if an exception is thrown then the client will receive TransactionRolledbackException if the client is remote and TransactionRolledbackLocalException if the client is local.

If the bean uses any other attribute then javax.ejb.EJBException is thrown.

Is the exception thrown is dependent on the transaction Attribute?

Also what I noted is with Bean Managed Transaction Demarcation, the exception thrown is javax.ejb.EJBException for local client.Pls clarify

Thanks and Regards
Shiv
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please reread the question carefully. The information is there to tell you if the question is correct or incorrect. This is the kind of question that can easily cost you points in the real exam if you are just a little careless of if you do not know the exception hierarchy.

Let me give you another hint: what is the difference between an exception thrown to a local client and an exception thrown to a remote client?
 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Roger,

Will client receive javax.ejb.EJBException ?
 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sanju,

The local client receives javax.ejb.TransactionRolledbackLocalException which is the subclass of javax.ejb.EJBException. The option 4 in the above question is incorrect because there is no class javax.transaction.TransactionRolledbackLocalException. The remote client receives javax.transaction.TransactionRolledbackException.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it is important to remember that a local client will receive javax.ejb.EJBException (or its subclasses) and a remote client will receive java.rmi.RemoteException (or its subclasses).

On a related subject, you must also know why you must sometimes convert a checked exception to EJBException. Perhaps I should have started a separate thread for this ...
 
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
As Durgaprasad pointed out.

The javax.transaction.TransactionRolledbackException is a subclass of java.rmi.RemoteException and is thrown for remote clients. Thus pont 5 is correct.

For local clients javax.ejb.TransactionRolledbackLocalException is thrown which is a subclass of javax.ejb.EJBException and in point 4 the package is worng.

As far as point 2nd is concerned in the bean class you can catch the application exception and can continue the transaction(may be calling other methods ) after checking that the transaction has not been marked for rollback but the client can't do the same.

Hope that helps.
 
ShivPrakash Srivastava
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Thanks for the feedback.Perhaps I need to read the question a little careful.

Thanks Roger

Regards
Shiv
 
reply
    Bookmark Topic Watch Topic
  • New Topic