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.
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: 244
posted
0
I agree with your answers, Amol.
Gemini
Jeff Walker
Ranch Hand
Joined: Apr 25, 2004
Posts: 116
posted
0
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.
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
posted
0
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: 13
posted
0
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.
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.