0

How to catch all exceptions in spring-3.0 mvc application?

I tried something like this:

public class CustomExceptionResolver extends SimpleMappingExceptionResolver { ... }

and

<bean class="com.web.controller.CustomExceptionResolver" autowire="byName">
    <property name="exceptionMappings">
        <props>
            <prop key="java.lang.Exception">uncaughtException</prop>
        </props>
    </property>
</bean>

But it's still not going to that class whenever I encounter exceptions. I can't use annotations (eg. @Controller, @ExceptionHandler, @ControllerAdvice)

Lastly, how to use @ControllerAdvice without annotations? Thanks.

M. Deinum
  • 115,695
  • 22
  • 220
  • 224
renz
  • 1,072
  • 3
  • 11
  • 21
  • does [this](http://candidjava.com/spring-mvc-with-simplemappingexceptionresolver-tutorial-and-example) and [this](http://www.mkyong.com/spring-mvc/spring-mvc-exception-handling-example/) help you – Ankur Singhal Sep 05 '14 at 04:17
  • you getting error when your spring context is getting loaded ? Just defining exception resolver in xml should work – coder Sep 05 '14 at 04:17
  • doesnt spring load those classes by type? you are using byName, maybe thats a reason. – hi_my_name_is Sep 05 '14 at 05:55

0 Answers0