aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes client view of exceptions 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 "client view of exceptions" Watch "client view of exceptions" New topic
Author

client view of exceptions

rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
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.


Cheers,<br />Rani<br />SCJP, SCWCD, SCBCD
amol deshpande
Ranch Hand

Joined: Sep 05, 2003
Posts: 162
Parmeet Sarpal ,
Would this help?

5) is correct..javax.transaction.TransactionRolledbackException is system exception and would apply sementics of System Exception.
if you'r thinking about (4) , packate should be javax.ejb.....
Amol.
Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
So the answer 2 & 5 are correct.

Right, Amol?

Gemini

[ March 21, 2005: Message edited by: Gemini Moses ]
[ March 21, 2005: Message edited by: Gemini Moses ]
rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
According to www.ejbcertificate.com the correct answer is 5. Why not 2?
ravi janap
Ranch Hand

Joined: Nov 04, 2000
Posts: 389
Hi

(2) is wrong since the DB is in indeterministic state because of the data changes done using the prior business method call which should have either been rolled back or committed before the client makes a safe business method call again.

Thanks

Ravi


SCJP, SCJD, SCWCD, SCBCD, SCEA
rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
Ravindra, it sounds good
Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
Instead of
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.

If the statement would have been
The client can safely continue the transaction by handling the exception and retrying the operation if an application exception is received, but only after checking the transaction has not been marked for rollback.

Would it have been correct answer?

Thanks,
Gemini
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
I think option 2 is rather unclear. It depends on how you might interprete "continue" to be. Is it without any attempts to handle the exception? Or it meant handling the exception & retry to commit.


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
amol deshpande
Ranch Hand

Joined: Sep 05, 2003
Posts: 162
Hi there,
Gemini,
Again, this is ejb certificate question and as most its unclear about its meaning.But if its only 1 answer you have to choose ,go for 5.
Amol.
ravindra janapreddy
Ranch Hand

Joined: Jan 30, 2001
Posts: 84
Hi

Specifications says

The EJB specification for exception handling is designed to meet these high-level goals:
� An application exception thrown by an enterprise bean instance should be reported to the client precisely (i.e., the client gets the same exception).
� An application exception thrown by an enterprise bean instance should not automatically rollback a client�s transaction. The client should typically be given a chance to recover a transaction from an application exception.
� An unexpected exception that may have left the instance�s state variables and/or underlying persistent data in an inconsistent state can be handled safely.

Thanks

-- Ravi
[ March 27, 2005: Message edited by: ravindra janapareddy ]

SCEA, SCBCD, SCWCD, SCJD, SCJP
ravi janap
Ranch Hand

Joined: Nov 04, 2000
Posts: 389
Hi

I want to revise my previously statement that (2) is "wrong" to (2) is "right" and this is because while reading EJB specs, I have come across this:

If a client program receives an app exception from an EJB invocation while the client is associated with a tx, the client can typically continue the tx because an app exception does not automatically cause the container to mark the tx for rollback.

Although the container does not automatically mark for rollback a tx because of a thrown app exception, the tx might have been marked for rollback by the EJB instance before it threw the app exception.

There are two ways to learn if a particular app exception results in tx rollback or not:
� Statically. Programmers can check the docs of the EJB�s home or component interface. The Bean Provider may have specified the app exceptions for which the EJB marks the tx for rollback before throwing the exception.
� Dynamically. Clients that are EJB with container-managed transaction demarcation can use the getRollbackOnly method of the javax.ejb.EJBContext object to learn if the current tx has been marked for rollback; other clients may use the get-Status method of the javax.transaction.UserTransaction interface to obtain the tx status.

Thanks

-- Ravi
[ March 28, 2005: Message edited by: Ravindra Janapareddy ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: client view of exceptions