wood burning stoves 2.0*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Application Exception in Stateless BMT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Application Exception in Stateless BMT" Watch "Application Exception in Stateless BMT" New topic
Author

Application Exception in Stateless BMT

Diana Finis
Greenhorn

Joined: Jan 27, 2003
Posts: 11
Hi All,
For Stateless bean with BMT:
If a bean method in tx neither commits nor rollbacks the tx and throws an Application Exception, what happens to tx and what exception client receives?
1.From one side App Exception doesn't automaticly causes tx to rollback, 2.from another side Stateless must to end the tx before returning from the method.
Spec says that App Exception is propagated to client always, but this is contradicting to side 2.
So what is the answer?
Thanks, :roll:


Diana<p>--------<br />SCJP<br />SCWD<br />Passed IBM Portal Multiplatform Implementation
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Hi Diana,
From the EJB specification, page 356:
If a stateless session bean instance starts a transaction in a business method, it must commit the transaction before the business method returns. The Container must detect the case in which a transaction was started, but not completed, in the business method, and handle it as follows:
  • Log this as an application error to alert the system administrator.
  • Roll back the started transaction
  • Discard the instance of the session bean
  • Throw the java.rmi.RemoteException to the client if the client is a remote client, or throw the javax.ejb.EJBException if the client is a local client.


  • From this, I believe the Container would enforce rule 2.
    Regards, Andrew
    [ September 23, 2003: Message edited by: Andrew Monkhouse ]

    The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
    Diana Finis
    Greenhorn

    Joined: Jan 27, 2003
    Posts: 11
    Thanks Andrew,
    It makes sense now. So even if bean throws an AppException without ending a tx, container will respond as you described instead of propagating AppException to the client.
    Am I right?
    Thanks,
    Diana
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander

    Joined: Mar 28, 2003
    Posts: 11404
        
      81

    Hi Diana,
    Correct.
    Regards, Andrew
     
     
    subject: Application Exception in Stateless BMT
     
    Similar Threads
    Stateful session bean with Bean Managed Transaction
    Last moment suggestions???
    2 questions about exceptions
    Last Minute Beta Tips
    hurray passed SCBCD!!!!!!!!!