Override default exception hander

Dear Team,
Can i customize an exist exception handler of framework ?
Example NoUserSessionHandler ,i want to foward into login screen immediately after session expired.


There are two types of exception handlers in the platform and both can be overridden.

The first type is explained in the docs: Client-Level Exception Handlers - CUBA Platform. Developer’s Manual. To override such handler, use standard procedure of overriding beans as explained here: Extending Business Logic - CUBA Platform. Developer’s Manual, i.e. just register a new class with the same id in web-spring.xml.

NoUserSessionHandler belongs to the second type of handlers. To override it, specify an instance of ExceptionHandlersConfiguration bean in your web-spring.xml with a unique identifier and register your extended handler with it, for example:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">

    <!-- Annotation-based beans -->
    <context:component-scan base-package="com.company.sample"/>

    <bean id="sample_exceptionHandlersConf" class="com.haulmont.cuba.web.exception.ExceptionHandlersConfiguration">
        <property name="handlerClasses">


Example of the overridden handler:

package com.company.sample.web;

import com.haulmont.cuba.web.App;
import com.haulmont.cuba.web.exception.NoUserSessionHandler;

import javax.annotation.Nullable;

public class SampleNoUserSessionHandler extends NoUserSessionHandler {

    protected void doHandle(App app, String className, String message, @Nullable Throwable throwable) {
        app.getWindowManager().showNotification("Hello from SampleNoUserSessionHandler");

All handlers of the second type specified in the project comes into play before provided by the platform, so your handler will effectively replace the default one.