Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Application Exception in Stateless BMT

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
     
    Diana Finis
    Greenhorn
    Posts: 11
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
    Posts: 12199
    280
    Mac IntelliJ IDE Firefox Browser Oracle C++ Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Diana,
    Correct.
    Regards, Andrew
     
    reply
      Bookmark Topic Watch Topic
    • New Topic