BeforeEnterListener Error (solved)

I am encountering an issue with the beforeEventListener in my Vaadin project and I could really use some assistance.

To give some context, I downloaded an empty Vaadin starter project and implemented the necessary classes to enable user login. However, I’m currently unable to display the login form error upon a failed login attempt.

Interestingly, I also downloaded the source code from the Vaadin Youtube tutorial titled “Spring Boot Web App Tutorial (Java) | Full Course,” and when running that code, the failed login error message appears as expected. Unfortunately, I haven’t been able to identify the cause of the discrepancy between my basic starter project and the tutorial code.

Instead of showing the anticipated error message, the browser reloads with the “/login?error” query parameter, yet no error is displayed. Moreover, it seems that my beforeEnter method isn’t being invoked when the LoginView is loaded.

It appears that the Vaadin starter project I downloaded is missing a crucial element for the proper functioning of the BeforeEventListener interface.

Being a passionate student, I have dedicated a significant amount of time and effort to this project. However, I’ve hit a roadblock and currently feel quite stuck. I would sincerely appreciate any assistance or guidance anyone could provide to help me overcome this hurdle.

BeforeEnterListener Error

Here is my LoginView class: @Route(“login”)
@PageTitle(“Login | …”)
public class LoginView extends VerticalLayout implements BeforeEnterListener {

LoginI18n i18n = LoginI18n.createDefault();
LoginForm loginForm = new LoginForm();

public LoginView() {
    LoginI18n.Form i18nForm = i18n.getForm();
    i18n.setAdditionalInformation("If you are experiencing issues " +
            "logging into your account, please contact ...");




            new H1("..."),
            new H3("..."),

public void beforeEnter(BeforeEnterEvent beforeEnterEvent) {

    // inform the user about an authentication error
            .containsKey("error")) {


You probably need BeforeEnterObserver instead of your current BeforeEnterListener

The BeforeEnterObserver fixed the issue. Thank you very much @quirky-zebra

BeforeEnterListener Error (solved)