aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Exception handling in J2EE layered projects- Best practices Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Exception handling in J2EE layered projects- Best practices" Watch "Exception handling in J2EE layered projects- Best practices" New topic
Author

Exception handling in J2EE layered projects- Best practices

chets patel
Ranch Hand

Joined: Apr 27, 2010
Posts: 72

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

Joined: Apr 27, 2010
Posts: 72

No body is there to answer my question
Please help if any one knows the ans
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception handling in J2EE layered projects- Best practices
 
Similar Threads
NX: Remote/IOException in DBServices interface (Ken...?)
Can you throw too many exceptions?
Robust Java: TOC?
throw/(s) runtime exception
Design of Exception Handling in Enterprise System.