aspose file tools*
The moose likes Other Application Frameworks and the fly likes Spring Exception Handling Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Spring Exception Handling Problem" Watch "Spring Exception Handling Problem" New topic
Author

Spring Exception Handling Problem

nitin pai
Ranch Hand

Joined: May 30, 2006
Posts: 185
In my DAO, I try to catch a generic Spring exception i.e DataAccessException for all type of DB problems. Then I wrap the message from it into my custom business exception.

But still, when I try to add a record with an existing primary key the application throws a stack trace of org.hibernate.exception.ConstraintViolationException without proceeding into the catch block of DataAccessException.

I even tried catching the most generic form i.e Exception. Here too, the application fails and throws the same stack trace. How can I catch this exception without failing the application.

I am using hibernate 3 with spring 2. The code which I am referring to is:



and the stack trace on this execution is:




Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Do you have the PersistenceExceptionTranslationPostProcessordefined in your configuration. With JdbcTemplate it is there automatically, but with Hibernate you need to add it to your configuration



Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
 
subject: Spring Exception Handling Problem