*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Can the client continue after getting the exception ??? and other doubts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Can the client continue after getting the exception ??? and other doubts" Watch "Can the client continue after getting the exception ??? and other doubts" New topic
Author

Can the client continue after getting the exception ??? and other doubts

Narasimha Rao B.
Ranch Hand

Joined: Aug 26, 2002
Posts: 205
Hi,
Please clarify me the below doubt,

1. Client call the method with in the transaction context, bean has rolled back the transaction, now the client gets, TransactionRolledBackException. If the user wants to continue the transaction, can he continue ( Even he may not commit the transaction at the end)

2. From the select statement can i select the more than one cmp field, i.e. "select e.name, e.empno from employee as e"

3. I saw in one of the material, "ONLY message-driven beans can asynchronously receive messages." --> What it means?

Thanks in Advance..


Narasimha
Keerthi P
Ranch Hand

Joined: Aug 19, 2003
Posts: 203
1. Client call the method with in the transaction context, bean has rolled back the transaction, now the client gets, TransactionRolledBackException. If the user wants to continue the transaction, can he continue ( Even he may not commit the transaction at the end)

-- When the client receives it, the transaction has already been rolled back. All the client can do is retry the transaction. i.e., lookup home and re-invoke the method, for example.

3. I saw in one of the material, "ONLY message-driven beans can asynchronously receive messages." --> What it means?

-- This means that a MDB's client need not have to wait till onMessage() method returns. Clients can simply send message and proceed with the processing. You can assume as if you are spawing a thread when you send in a message to a MDB.
[ August 17, 2004: Message edited by: Keerthi P ]

Cheers.<br />Keerthi<br />(SCJP, SCWCD, SCBCD)
Giju George
Ranch Hand

Joined: Jun 08, 2004
Posts: 333



-- When the client receives it, the transaction has already been rolled back. All the client can do is retry the transaction. i.e., re-invoke the method, for example.


By the time the client gets this exception, the container might have discarded the bean instance. So the client won't be able to call the method again !!


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCEA
Narasimha Rao B.
Ranch Hand

Joined: Aug 26, 2002
Posts: 205
Thanks to Giju and Keerthi.

"By the time the client gets this exception, the container might have discarded the bean instance. So the client won't be able to call the method again !! "

Here i didn't say, bean has thrown the exception.
Take the case - there is no exception any where and the beans wants to roll back the transaction, hence he called the method setRollbackOnly(), then the transaction is rolled back and the client get the TransactionRolledBackException(). In this case client can continue with the instance.
Take other case - there is a system exception, then the transction will be rolled back, bean instance will be discarded. Now the client gets, TransactionRolledBackException, in this case client can not continue with the instance, because the instance has been discarded.

If i am wrong, please correct me..
Keerthi P
Ranch Hand

Joined: Aug 19, 2003
Posts: 203
If setRollbackOnly() has been called and the container has to rollback the transaction, it will *NOT* throw TransactionRolledbackException just to indicate the client that the transaction has been *successfully* rolled back.

TransactionRolledbackException will *ONLY* be thrown if for some reason the container cannot COMMIT the transaction in a CMT method running in the context of a transaction.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can the client continue after getting the exception ??? and other doubts
 
Similar Threads
Question about exception
Question from ejbcertificate.com on Exception
TrasactionRolledbackException
application exception
Qn about exceptions from ejbcertificate