Announcement Announcement Module
Collapse
No announcement yet.
how to convert IllegalAccessException to DataAccessException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to convert IllegalAccessException to DataAccessException

    I use class "org.apache.commons.beanutils.BeanUtils" in a dao method.

    it throws java.lang.IllegalAccessException and
    java.lang.reflect.InvocationTargetException.

    I want to convert the exceptions to org.springframework.dao.DataAccessException;

    which implements of DataAccessException seemly for instead?

  • #2
    DataAccessExceptions are converted from SQLExceptions using a SQLExceptionTranslator which is a property of the JdbcTemplate class. It doesn't appear there is a way to capture non-SQLExceptions and convert them to another exception type.

    The only way I think of fixing this is to implement a subclass of BeanUtils to intercept the desired exceptiosn and throw DataAccessExceptions.

    Comment


    • #3
      You can simply catch the exception and throw an appropriate subclass of DataAccessException (probably a subclass of one of the existing classes lower down).

      Comment

      Working...
      X