Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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 ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Non application exception in local client

Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A question about exception on ejbcertificate site

If a local client in a transaction context invokes a business method on a bean with container-managed transactions, what exception does the client receive if the bean instance throws a non-application exception?

The answer is javax.ejb.TransactionRolledbackLocalException, why is it not javax.ejb.EJBException?

This really confuses me

When the transaction is rolled back by CONTAINER in the result of system exception, and a client try to commit the transaction, transactionRolledback(Local)Exception will thrown.

When the transaction is marked rollback only by bean, and a client try to commit the transaction, the TransactionRolledback(Local)Exception will NOT thrown.

Am I right ?
Why is TransactionRolledback(Local)Exception thrown in the above situation?

Shiang Wang
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After I review Val's cheap sheet on exception, I realize this has something to do with if the tx is started by the caller or not. If the exception occurs in the same tx context as the caller, the TransactionRolled(Local)backException will be thrown, otherwise client will receive either EJBException or RemoteException.

Oh another thing I like to clear out, just for my own benefit, is that bean provider can't never throw RemoteException, it should be always wrapped as an EJBException. The remote client will receive RemoteException, local client will receive EJBException.

Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic