• 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 in J2EE layered projects- Best practices

 
Ranch Hand
Posts: 77
Eclipse IDE Tomcat Server Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I read lots of posts regarding exception handling in J2EE projects and learnt following points.
1. Method signature should throw only checked exception

2. We need to catch the checked exception and rethrow runtime exception by wrapping it.

3. Logging should be done only once for any exception.

These may be very simple points for you but I am very much confused. I have following doubts. It would be great if you clarify my doubts.
1. Suppose I am using spring and I want to handle DataAccessException(Which is runtime exception) in service layer
a) should I do catch(DataAccessException e) in my service layer
If Yes: Many people say that you do not need to catch runtime exception.
If No: How will I handle it in my application if such exception occurs. Is it good practice to propagate my DataAccessException till Action layer?

b) on what basis I should convert the checked exception into uncheked exception(referencing to point 2 above). It would be better if you can provide any example.

c) How to handle run time exceptions if I am not supposed to catch runtime exception. Somewhere I have to catch the runtime exception


I know that many times it is dependent on the requirements from the customer, but I just want to know about best practices about exception handling.

Thanks in advance
 
chets patel
Ranch Hand
Posts: 77
Eclipse IDE Tomcat Server Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No body is there to answer my question
Please help if any one knows the ans
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic