Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transaction Problem

 
phenix java
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just found this problem.But I confuse about those answer.

Which is the true about the client's view of exception received from an ejb?

A) Receiving an application exception communicates to the client that the bean will no longer be accessible
B) The client of a CMT bean can determine if the transaction has been roll back by calling the getStatus() method of the java.transaction.UserTransaction interface
C) If the client receives an EJBException,the client must discontinue the transaction.
D)If the client receives the java.rmi.RemoteException exception, the client will not typically know whether the method has completed.

-------------------------------------------------------
When the first I read this question.I thought answer of this question is C.
But I already read all answer.I confuse between C and D.

Would someone please explain reason to choose C or D is correct

Thank you for kindness
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
C) If the client receives an EJBException,the client must discontinue the transaction.

Wrong. The Container has already rolled back the transaction and is simply informing the client.

D)If the client receives the java.rmi.RemoteException exception, the client will not typically know whether the method has completed.

Correct. RemoteException can be thrown for a large number of reasons. In fact, it can be thrown before the method even begins. For example, if a user calls a bean method with an invalid security role the Container will throw a RemoteException to a remote client.
 
chao cai
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
about C
if the transcation is CMT ,it will rollback;
but if the transcation is Client transcation ,what can you do?
 
Murali Kurukunda
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
about C
if the transcation is CMT ,it will rollback;
but if the transcation is Client transcation ,what can you do?

I think its upto the client to decide whether to rollback the transaction or not, if the client has its own transaction.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's say that the transaction starts in a CMT client bean (A) which makes a local method call on another bean (B). If EJBException is then received by A, the Container will rollback A's transaction.

If A is a BMT bean, then A will probably end the transaction by invoking UserTransaction.rollback(). But note that if UserTransaction.setRollBackOnly() is invoked either in A or B (this assumes that A's transaction propgates into B, which must be a CMT bean with a Required, Mandatory or Supports transaction attribute), the Container will always rollback the transaction.

Back to question C: it is wrong because of the highlighted word "must":
If the client receives an EJBException,the client must discontinue the transaction.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic