Side Menu Vaadin8

Hi everybody,

I’m trying to do a sidebar to navigate between different pages, I using this code:

public class FormacionEjemplo5 extends UI {

	public static final String SELECTORES = "selectores";
    protected void init(VaadinRequest vaadinRequest) {
//    	Titulo del menu
    	Label label = new Label("Menú de Contenidos");
//    	Secciones
    	Button button1 = new Button("Botones", e -> getNavigator().navigateTo("botones"));
    	button1.addStyleNames(ValoTheme.BUTTON_LINK, ValoTheme.MENU_ITEM);
//    	Menu
    	CssLayout menu = new CssLayout(label, button1);
    	CssLayout contenido1 = new CssLayout();
    	HorizontalLayout mainLayout = new HorizontalLayout(menu, contenido1);
//    	Contenido de la navegacion
    	Navigator navigator = new Navigator(this, contenido1);
    	navigator.addView("", Default.class);
    	navigator.addView("botones", Botones.class);

And when I enter in the web and push the button always throw this error:

Can someone help me please?

The exception most likely occurs when calling getNavigator().navigateTo(“botones”) tries to instantiate the view Botones.class. Why this is happening is not revealed by the information provided by you. Sharing Botones.class code and full stacktrace could help Forum readers to spot potential issue there.

Finally I solved it but I don’t know how, I show the code if someone can find the previous error:

package com.example.Vistas;

import com.vaadin.icons.VaadinIcons;
import com.vaadin.navigator.View;
import com.vaadin.ui.Button;
import com.vaadin.ui.Composite;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.themes.ValoTheme;

public class Botones extends Composite implements View{ 

	public Botones () {
//		setSizeFull();
		HorizontalLayout horizontalLayout = new HorizontalLayout();
		Button boton1 = new Button("Azul sin borde");
		Button boton2 = new Button("Verde y Gordo");
		Button boton3 = new Button("Rojo y Chiquitin");
		Button boton4 = new Button("Youtube");
		Button boton5 = new Button("Diamante");
		Button boton6 = new Button("Cartera");
		boton1.addStyleNames(ValoTheme.BUTTON_PRIMARY, ValoTheme.BUTTON_BORDERLESS);
		boton2.addStyleNames(ValoTheme.BUTTON_FRIENDLY, ValoTheme.BUTTON_HUGE);
		boton3.addStyleNames(ValoTheme.BUTTON_DANGER, ValoTheme.BUTTON_TINY);
//		boton6.setIcon(VaadinIcons.WALLET);
//		boton6.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
//		horizontalLayout.addComponents(boton1,boton2,boton3,boton4,boton5,boton6);
//		setCompositionRoot(horizontalLayout);
		horizontalLayout.addComponents(boton1, boton2, boton3, boton4, boton5);

I was commenting lines to solve the error.

Thanks a lot for the help.