Announcement Announcement Module
Collapse
No announcement yet.
Exception Handling Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exception Handling

    Hi!

    I'm developing a Spring MVC web app following the stack:
    @Controller
    @Service@Transactional
    @Repository

    I inserted the org.springframework.dao.annotation.PersistenceExce ptionTranslationPostProcessor in my applicationContext.xml

    and in my spring-servlet:
    Code:
        <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
            <property name="exceptionMappings">
                <map>
                    <entry key="DataAccessException" value="dataAccessFailure"/>
                </map>
            </property>
        </bean>
    I found out that if in my controller i call directly the DAO the DataAccessException is caught, while if I use the service it does not.
    It can be obvious because it is raised an unchecked exception, but the question is: How to propagate the DataAccessException in order to be caught by the SimpleMappingExceptionResolver?

    Should I have to use a try catch(DataAccessException) block in the service? I tried but it's not caught..

    Another question: where is it useful insert log? In the DAO or in the service?
    What is the best practise?

    Thank you in advance

  • #2
    If i insert

    Code:
    <error-page>
            <exception-type>java.lang.Exception</exception-type>
            <location>/WEB-INF/jsp/dataAccessFailure.jsp</location>
        </error-page>
    In my web.xml .. it's showed the /web-inf/jsp/dataaccessfailure.jsp outside my tiles ..

    Should runtimeexception be propagated to the controller passing via Service layer?

    Comment

    Working...
    X