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

Showing results for 
Search instead for 
Did you mean: 
Member II

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

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?

1 Reply

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

Alfresco does not use Spring Boot, just simple Spring beans. Nothing is looking for or using any exception handler or resolver, so defining one has no effect at all. In short, there is no support for adding generic / global exception handlers in Alfresco Content Services - exception handling is done as part of the individual ReST API operation code.