• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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
 
Don't listen to Steve. Just read this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic