AnsweredAssumed Answered

How configure global exception handler in alfresco CE 5.1.f?

Question asked by v.yaml on Dec 20, 2018
Latest reply on Dec 21, 2018 by afaust

I trying configure global exception handler, but it doesn't work.

1-st variant:

public class ExHandler extends ResponseEntityExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    protected ResponseEntity<Object> handleConflict(Exception ex, WebRequest request) {
        String bodyOfResponse = "This should be application specific";
        return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.CONFLICT, request);

2-nd variant:

public class ExResolver extends AbstractHandlerExceptionResolver {
    public int getOrder() {
        return Integer.MIN_VALUE;

    protected ModelAndView doResolveException
            (HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
        try {
            if (ex instanceof IllegalArgumentException) {
                return handleIllegalArgument((IllegalArgumentException) ex, response);
        } catch (Exception handlerException) {
            logger.warn("Handling of [" + ex.getClass().getName() + "] resulted in Exception", handlerException);
        return null;

    private ModelAndView handleIllegalArgument(IllegalArgumentException ex, HttpServletResponse response) throws IOException {
        return new ModelAndView();



<?xml version='1.0' encoding='UTF-8'?>
<!-- This is a sample configuration file from Alfresco Community - Please adapt to your version -->
<beans xmlns=""

    <context:component-scan base-package="net.example.alfresco"/>

Beans success created, but it not work


What am I missing or doing wrong?