Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

new ejbcertificate.com question

 
amol deshpande
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with your answers, Amol.

Gemini
 
Jeff Walker
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Srini Madala
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
amol deshpande
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic