• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJBException dooms transaction?

 
David Yuan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am seeing a mock test question that asks if to throw a EJBException from a CMT bean will roll back the current transaction if any.
I searched in EJB specs, all I found that is to throw a Application exception will not doom the transaction. I don't see it mentions anywhere if to throw an EJBException will doom the Tx.
So I am at a loss, can somebody share some insight on this?
-David
 
David Yuan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops, I found out the answer. The EJB specs does say to throw an EJBException will doom the Tx.
In section "18.2.2 System Exceptions", it says:
The Bean Provider can rely on the container to perform the following tasks when catching a non-application exception:
� The transaction in which the bean method participated will be rolled back.
� No other method will be invoked on an instance that threw a non-application exception.
-David
 
David Peterson
author
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An EJBException indicates a problem within the container itself (e.g. you are trying to access an object that no longer exists), rather than an application (business logic) issue.
If an EJBException is thrown it indicates a bug in your code or the configuration of the container. The transaction will not be committed.
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check this out - http://www.valoxo.ch/jr/ExceptionHandling.pdf
 
David Yuan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ajith,
Thanks! The .pdf is great!
-David.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic