View is not a Component

Hi!

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(View.java:93)
at com.vaadin.navigator.Navigator$SingleComponentContainerViewDisplay.showView(Navigator.java:305)
at com.vaadin.navigator.Navigator.performNavigateTo(Navigator.java:773)
at com.vaadin.navigator.Navigator.lambda$navigateTo$9a874efd$1(Navigator.java:702)
at com.vaadin.navigator.Navigator.runAfterLeaveConfirmation(Navigator.java:726)
at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:701)
at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:678)
at com.vaadin.ui.UI.doInit(UI.java:775)

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:
@Override
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.