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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "new ejbcertificate.com question" Watch "new ejbcertificate.com question" New topic
Author

new ejbcertificate.com question

amol deshpande
Ranch Hand

Joined: Sep 05, 2003
Posts: 162
How will the EJB container handle exceptions thrown by a business method of a bean with container managed transaction demarcation? [Check all correct answers]

1. If the instance called setRollbackOnly(), the EJB container will rollback the transaction.

2. If the instance did not call setRollbackOnly(), the EJB container will commit the transaction.

3. The EJB container will throw a RemoteException.

4. If the bean represents an entity bean, it will remove the entity from the datasource.

5. If the bean represents a session bean, the bean will be removed from the pool.


ejbcertificate.com answers:1,2

My views:
1) This is OK , in both cases, App exceptions and System Exceptions, if bean calls setRollbackOnly , Tx will be rollbacked.

2)if Instance didn't call setRollbackOnly, which exception is it ...this decides for what container does....for App Exceptions, container doesn't rollback Tx nor does it commit, it allows Tx to be continued.
But if its Sys exception, Tx is rollbacked.

3) NO Gurentee

4)Database entry is not removed...!!!

5)If its session it will be removed from pool (i think talkin about discarding the instance..)..only if its Sys exception....


I selected 1,2, but since ques. is unclear about type of exception, I was wrong in the context of question.
Please correct me if necessary.
What do ya think?
Amol
Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
I agree with your answers, Amol.

Gemini
Jeff Walker
Ranch Hand

Joined: Apr 25, 2004
Posts: 116
Originally posted by amol deshpande:
How will the EJB container handle exceptions thrown by a business method of a bean with container managed transaction demarcation? [Check all correct answers]

1. If the instance called setRollbackOnly(), the EJB container will rollback the transaction.

2. If the instance did not call setRollbackOnly(), the EJB container will commit the transaction.

3. The EJB container will throw a RemoteException.

4. If the bean represents an entity bean, it will remove the entity from the datasource.

5. If the bean represents a session bean, the bean will be removed from the pool.


ejbcertificate.com answers:1,2

My views:
1) This is OK , in both cases, App exceptions and System Exceptions, if bean calls setRollbackOnly , Tx will be rollbacked.

2)if Instance didn't call setRollbackOnly, which exception is it ...this decides for what container does....for App Exceptions, container doesn't rollback Tx nor does it commit, it allows Tx to be continued.
But if its Sys exception, Tx is rollbacked.

3) NO Gurentee

4)Database entry is not removed...!!!

5)If its session it will be removed from pool (i think talkin about discarding the instance..)..only if its Sys exception....


I selected 1,2, but since ques. is unclear about type of exception, I was wrong in the context of question.
Please correct me if necessary.
What do ya think?
Amol



Tough question.
EJB 2.0 Spec page 376 has a table that backs up your answer.
The 2.0 EJB Spec can be found at: http://java.sun.com/products/ejb/docs.html
Enjoy,
-jeff walker
Stefan Guilhen
Ranch Hand

Joined: Jul 31, 2004
Posts: 61
Hi all,

I think the question is not clear enough. Answers can be correct/incorrect depending on the type of the exception thrown. It is a relief the questions on the real exam are all clear, like the ones you find in HF-EJB mock exam and unlike this one.


SCJP 1.4, SCBCD 1.3<br />IBM 141, 484, 486
Srini Madala
Greenhorn

Joined: Feb 27, 2005
Posts: 16
I totally agree with Amol. The questions on ejbCertification.com are too vague. I just gone through this exceptions one an hour ago. I too got the same doubt.

*******************************************************************
2)if Instance didn't call setRollbackOnly, which exception is it ...this decides for what container does....for App Exceptions, container doesn't rollback Tx nor does it commit, it allows Tx to be continued.
But if its Sys exception, Tx is rollbacked.
*************************************************************************

Even if the questions says that it throws application exception, it is still vague to answer option 2. This option seems to be correct only if the method has a "RequiresNew" transaction flag. Otherwise the transaction will continue to run in client's Tx, without commit.

We are not sure what to do if such questions come in exams.


Srini Madala<br /> <br />SCJP2, SCWCD1.3, SCBCD1.3
amol deshpande
Ranch Hand

Joined: Sep 05, 2003
Posts: 162
Hello friends,
Special thanks to Gemini,Jeff,Stephan and Srini. Its great that you all take time and care to post your views.
Ejbcertificate.com questions are a little vague and sometimes do not describe what exactly is the scenario author is imagining as it leaves us with lots of options to consider and each option gives different set of answers!!!
I posted feedback on 5 questions there, but I didnt get any reply as of its processing.
We must also condiser the fact that this is a free service and should thank them for providing the valuable service.
Amol.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: new ejbcertificate.com question
 
Similar Threads
Exception question
Exception handling - regarding
ejb certificate exam que
CMT and Business method exceptions - question
My Study Notes