View is not a Component


Have a situation that can’t solve by myself.

A basic app with Navigator (+some views) and @PushStateNavigation.
MainView using empty url string (ex http://site/)
Other views have their “connectors” (ex http://site/view1 - > View1, http://site/view2 → View2, etc).

But when I entering other urls, for example http://site/somestring, I have an error:
java.lang.IllegalStateException: View is not a Component. Override getViewComponent() to return the root view component
at com.vaadin.navigator.View.getViewComponent(
at com.vaadin.navigator.Navigator$SingleComponentContainerViewDisplay.showView(
at com.vaadin.navigator.Navigator.performNavigateTo(
at com.vaadin.navigator.Navigator.lambda$navigateTo$9a874efd$1(
at com.vaadin.navigator.Navigator.runAfterLeaveConfirmation(
at com.vaadin.navigator.Navigator.navigateTo(
at com.vaadin.navigator.Navigator.navigateTo(
at com.vaadin.ui.UI.doInit(

What is it?
And how to catch such events? (I have errorView, but it’s not working)

The correct patter of creating View class is something like below. I.e. you need to extend some component, usually a base layout that fits your case and implement View interface. Navigator will then place this base component in target component container given to Navigator when it was instantiated.

public class MyView extends VerticalLayout implements View {

Yes, of course. This is not my first Vaadin application.
All my views are " extends VerticalLayout implements View ".

I’ve even tried to override getViewComponent() in such way:
public Component getViewComponent() {
return this;

But it did not help.

“… All my views…”
All, but except ErrorView :slight_smile:

Thank you, Tatu!

Problem is solved.