• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception Handling

 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Here's what we follow in handling exceptions in our design. I want your comments on the same and want to know any other better approaches.
We throw Application exception (extends java.lang.Exception) from the EJB layer, only in the case where we want to show some error message to the end user. So that he/she can change the entered data and proceed.We catch the application exception in weblayer and display the error message back to the end user.
System exception (extends java.lang.RunTimeException) is thrown from the EJB layer for any error related to the configuration. For example if EJB A is looking for EJB B, in the method of EJB A where we lookup for EJB B, we catch "namingException" (thrown by the lookup() method of the InitialContext) and throw a SystemException, because throwing "naming exception" back to the presentation layer doesnt make any sense to the end user since the exception has occured due to the EJB developer/deployer mistake. The System exceptions are not caught by the presentation layer but configured in the web.xml to redirect the user to a common error page.
[ May 27, 2003: Message edited by: Hari babu ]
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Hari babu:
Hi,
We throw Application exception (extends java.lang.Exception) from the EJB layer, only in the case where we want to show some error message to the end user. So that he/she can change the entered data and proceed.We catch the application exception in weblayer and display the error message back to the end user.
May 27, 2003: Message edited by: Hari babu ]


Throwing application exceptions does'nt result in automatic rollback.
If you are lookign for rollback, try doing a
ejbContext.setRollBackOnly() before throwing the exception. This s'd mark the transaction for rollback. It might help you in case there were partial updates to the DB.
 
I’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic