aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Question from ejbcertificate.com on Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Question from ejbcertificate.com on Exception" Watch "Question from ejbcertificate.com on Exception" New topic
Author

Question from ejbcertificate.com on Exception

ShivPrakash Srivastava
Ranch Hand

Joined: Mar 24, 2005
Posts: 88
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
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
I'll drop a hint why (4) is incorrect: Are you sure that a client can ever receive javax.transaction.TransactionRolledbackLocalException?


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
ShivPrakash Srivastava
Ranch Hand

Joined: Mar 24, 2005
Posts: 88
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

Joined: Sep 29, 2002
Posts: 1683
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?
Sanju Thomas
Ranch Hand

Joined: Dec 29, 2004
Posts: 243
Roger,

Will client receive javax.ejb.EJBException ?
Durgaprasad Guduguntla
Ranch Hand

Joined: Oct 20, 2003
Posts: 99
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.


Thanks,<br />Durgaprasad<br />SCJP1.4, SCWCD1.4, SCBCD1.3,<br />SCEA
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
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 ...
sawan parihar
Ranch Hand

Joined: Aug 24, 2004
Posts: 250
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.


Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
ShivPrakash Srivastava
Ranch Hand

Joined: Mar 24, 2005
Posts: 88
Hi All,

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

Thanks Roger

Regards
Shiv
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question from ejbcertificate.com on Exception