Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Application Exception or Runtime Exception

 
Mahesh Asrani
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

While designing our current application (using EJB) we have decided to have a
few Business case exception

I am new to EJB & was going through the container's way of handling exception & found that
in case of CMT the container will rollback the Runtime Exceptions

Would it be a good idea to make all our business case exceptions extend to the Runtime Excpetion.

Are there any perils of this approach

Kindly ellaborate on the same


Rgrds
Mahesh
 
Binoj Viswanathan
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
if u make all UR biz exce..n a type of RuntimeExce..n, how will the client knows vat hav hapend?not onli contaner simpli remove the instance without calling ejbRemove()(in the case stateful session bean).this wil cause scalability issues.
u dont need to du that. u can handle such scenario by creating/throwing Application exce..n and then u call setRollbackOnly() in ejb context.
the txn will never committed in this case.
binoj v
 
Leena Diwan
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are standard approaches for handling exceptions in EJB. I recommend reading the exceptions chapter in some good book. Knowing how to go about it will surely help you. It is not as simple as saying do this and do that. You need to know 'when and why' also.

Regards,
Leena
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic