assertion error no child node found with id -1

I am using a Thread to check for messages on activeMQ and I keep getting this error after consuming a message into a bean and then revisiting the page or another page that consume a message


package com.fekiosk.kiosk;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONObject;

import com.fekiosk.kiosk.camel.BarCodeReaderBean;
import com.fekiosk.kiosk.camel.CheckReaderBean;
import com.fekiosk.kiosk.controllers.Cart;
import com.vaadin.flow.component.AttachEvent;
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.DetachEvent;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.dependency.CssImport;
import com.vaadin.flow.component.html.H1;
import com.vaadin.flow.component.html.H2;
import com.vaadin.flow.component.html.Image;
import com.vaadin.flow.component.html.Span;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.router.RouterLayout;
/**
* The main view contains a text field for getting the user name and a button
* that shows a greeting message in a notification.
*/

@Route("")
@CssImport("./styles/shared-styles.css")
@CssImport(value = "./styles/vaadin-text-field-styles.css", themeFor = "vaadin-text-field")

public class MainLayout extends VerticalLayout 
	implements RouterLayout
{
	public static 	TextField txtQRCode = new TextField();
	public static TextField  txtRouteNum =  new TextField ("Enter Bank Routing Number");
	public static TextField  txtAcctNum =  new TextField ("Enter Bank Account Number");
	private FeederThread thread;
   @Override
    protected void onDetach(DetachEvent detachEvent) {
        // Cleanup
        thread.interrupt();
        thread = null;
    }
		   
	@Override
    protected void onAttach(AttachEvent attachEvent) {
	 //       add(new Span("Waiting for updates"));

        // Start the data feed thread
        thread = new FeederThread(attachEvent.getUI(), this);
        thread.start();
    }

	/**
     * Construct a new Vaadin view.
     * <p>
     * Build the initial UI state for the user accessing the application.
     *
     * @param service
     *            The message service. Automatically injected Spring managed
     *            bean.
     */


	public static VerticalLayout header = new VerticalLayout(); //createHeader("Municipal Self-Service Payment Kiosk");
	public static VerticalLayout content = new VerticalLayout(); // createContent();
	public static VerticalLayout footer = new VerticalLayout(); //createFooter();
	public static List<Cart> CartHold = new ArrayList<Cart>();

    public MainLayout() {
    
      	txtRouteNum.getStyle().set("font-size","20px");
      	txtRouteNum.getStyle().set("font-weight","bold");
      	txtRouteNum.getStyle().set("font","Arial");
      	txtAcctNum.getStyle().set("font-size","20px");
      	txtAcctNum.getStyle().set("font-weight","bold");
      	txtAcctNum.getStyle().set("font","Arial");
    	setDefaultHorizontalComponentAlignment(Alignment.CENTER);
    	setSizeFull();
    	 header = createHeader("Municipal Self-Service Payment Kiosk");
    	 content = createContent();
    	 footer = createFooter();
  	
    	add(header,content,footer);
    	/*
		VaadinSession.getCurrent().setAttribute("CartHold", CartHold);

    	
*/
    }
    public static Component createHeader() 
    
    {
		VerticalLayout header = new VerticalLayout();
		header.setAlignItems(Alignment.CENTER);
		Image imgHeader = new Image("/img/Ft Wayne Utility web banner 3.jpg", "header");
		header.setWidth("100%");
		header.add(imgHeader);
		return header;
	
    }
	// HorizontalLayout header = new HorizontalLayout(new DrawerToggle());
    public static VerticalLayout createHeader(String heading)
    {
    	VerticalLayout header = new VerticalLayout();
    	header.setAlignItems(Alignment.CENTER);
    	H1 textHeader = new H1(heading);
		Image imgHeader = new Image("/img/Ft Wayne Utility web banner 3.jpg", "header");
		header.setWidth("100%");
		header.setHeight("350px");
		header.add(imgHeader, textHeader);
		return header;
    }
	public VerticalLayout  createFooter() {
		// HorizontalLayout header = new HorizontalLayout(new DrawerToggle());
		VerticalLayout footer = new VerticalLayout();
		footer.setAlignItems(Alignment.CENTER);
		
		Image imgFooter = new Image("img/FEKioskFooter.png", "footer");

		footer.setWidth("100%");
		footer.add(imgFooter);
		return footer;
	}
	public VerticalLayout createContent()
	{
		FELayout Lay = new FELayout();
     	VerticalLayout header = Lay.createHeader();
    	VerticalLayout footer = Lay.createFooter();
    	VerticalLayout content = new VerticalLayout();
    	VerticalLayout btnCart = Lay.vlCartLayout(0,0.00);
    	
    	content.setAlignItems(Alignment.CENTER);
    	
    	HorizontalLayout btnLayout1 = new HorizontalLayout();

    	H1 PageHeader = new H1("Municipal Self-Service Payment Kiosk");
    	H2 textHeader = new H2("This kiosk accepts payments by:");
    	Button btnWaterUtility = Lay.ButtonSmall("Water Utility");
    	Button btnParking = Lay.ButtonSmall("Parking Fines & Fees");
    	Button btnRETaxes = Lay.ButtonSmall("Real Estate Taxes");
    	Button btnDogLic = Lay.ButtonSmall("Dog Licenses");
    	Button btnExit = Lay.ButtonExit("Exit");
    	

    	btnWaterUtility.addClickListener( event ->  UI.getCurrent().navigate("WaterKiosk"));

		
    	btnLayout1.add(btnWaterUtility);
    	btnLayout1.add(btnParking);
    	btnLayout1.add(btnRETaxes);
       	btnLayout1.add(btnDogLic);
        
		header.setAlignItems(Alignment.CENTER);
		footer.setAlignItems(Alignment.CENTER);
		btnCart.setAlignItems(Alignment.CENTER);
		content.add(textHeader);
		content.add(new Span("Cash - Authentic US Currency, BILLS ONLY"));
		content.add(new Span("Credit Cards - Convenience Fee of " + Lay.ccCF + " will be added"));
		content.add(new Span("eChecks - Convenience Fee of " + Lay.eCheckCF + " will be added"));
		content.add(new Span("Money Orders - are NOT accepted at this kiosk"));
		content.add(btnLayout1);
		content.add(btnExit);
		content.setAlignItems(Alignment.CENTER);
		return content;
	}
	
	private static class FeederThread extends Thread {
        private final UI ui;
        private final MainLayout view;
        private boolean restart = false;
        private int count = 0;

        public FeederThread(UI ui, MainLayout view) {
            this.ui = ui;
            this.view = view;
        }

        @Override
        public void run() {
            try {
                // Update the data for a while
                while ( true ) {
                    // Sleep to emulate background work
                    FeederThread.sleep(500);
//                    if(! CardReadBean.cardReaderIntakeStack.isEmpty() ) {
//                        String value = CardReadBean.cardReaderIntakeStack.pop();
//                       	ui.access(() -> view.textArea.setValue( view.textArea.getValue() + value + "\n" ));
///                    }
                    
//                    if(! CashAcceptorBean.cashReaderIntakeStack.isEmpty() ) {
 //                       String value = CashAcceptorBean.cashReaderIntakeStack.pop();
//                       	ui.access(() -> view.cashAcceptor.setValue( view.cashAcceptor.getValue() + value  + "\n" ));
//                  }
                    
                    if(! BarCodeReaderBean.barcodeReaderIntakeStack.isEmpty() ) {
                        String value = BarCodeReaderBean.barcodeReaderIntakeStack.pop();
                        JSONObject json = new JSONObject(value);
                        String BarCodeEvent = json.get("barcodeevent").toString();            	    	Map params = new HashMap<String, List<String>>();
            	 
                        ui.access(() -> view.txtQRCode.setValue(BarCodeEvent.toString()));
                        restart = true;
//                        ui.access(() -> view.txtQRCode.setValue( view.txtQRCode.getValue() + value  + "\n" ));
                    }
                    
                    if(! CheckReaderBean.checkReaderIntakeStack.isEmpty() ) {
                        String value = CheckReaderBean.checkReaderIntakeStack.pop();
                        JSONObject json = new JSONObject(value);
                        String micrCode = json.get("micrCode").toString();
                        int checkNumDelimit = micrCode.indexOf("+");
                        if(checkNumDelimit > 0)
                        {
                        	String removeCheckNum = micrCode.substring(0, checkNumDelimit);
                            String[] CheckInfo = removeCheckNum.split("@");
                            ui.access(() -> view.txtRouteNum.setValue( CheckInfo[1]
));
                            ui.access(() -> view.txtAcctNum.setValue( CheckInfo[2]
));
                        }
                   }
                   
                }

                // Inform that we are done
				/*
				 * ui.access(() -> { view.add(new Span("Done updating")); });
				 */  
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
          }
    }    

}

–GetQRCode

package com.fekiosk.kiosk.views;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONObject;

import com.fekiosk.kiosk.FELayout;
import com.fekiosk.kiosk.MainLayout;
import com.fekiosk.kiosk.camel.BarCodeReaderBean;
import com.vaadin.flow.component.AttachEvent;
import com.vaadin.flow.component.DetachEvent;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.html.Image;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.router.Route;


@Route(value = "GetQRCode", layout = MainLayout.class)
public class GetQRCode extends VerticalLayout  

{

    public GetQRCode()
    {    	/* header and footer */
    	FELayout Lay = new FELayout();
    	VerticalLayout content = new VerticalLayout();
      	
    	HorizontalLayout hl1 = new HorizontalLayout();

      	Image QRImage = new Image("/img/BarCodeScanner-optimized.gif","header");
    	QRImage.setMaxHeight("300px");
    	QRImage.setMaxWidth("300px");
    	
    	hl1.add(MainLayout.txtQRCode,QRImage);
    	HorizontalLayout BottomLayout = Lay.searchCustNo("searchResult",  MainLayout.txtQRCode);

    	VerticalLayout btnCart = Lay.vlCartLayout(0,0.00);
        content.add( QRImage, MainLayout.txtQRCode, BottomLayout,btnCart);
    	btnCart.setAlignItems(Alignment.CENTER);
		content.setAlignItems(Alignment.CENTER);
		MainLayout.createHeader("Scan Bar Code");
		MainLayout.header.removeAll();
		MainLayout.header.add(content);
		
    	MainLayout.content.removeAll();
		MainLayout.content.add(content);

    }

    
}

I have the same problem when I authenticate using keycloak. When I route to my vaadin page I’m redirected to keycloak perform authentication then promptly fails with his error. From what I understand keycloak redirects back to my vaddin page. I have no answer yet.

I have further information that may help other users. I’m using Vaadin Ver 14.

My user interface uses AppLayout library to display a header/menu and client contents.

I disabled springboot security to the effected vaadin routes and it didn’t effect the problem.

I further investigated the stack dump and it seems to be a problem with routing and changing the contents to the UI, and attaching a node to the root node or something like that.

I tried two ways to get to my VerticalLayout window using a menu with AppLayout

  1. hooking an anchor(problems!!) which works with the httpsecurity and works with keycloak but after authenticating crashes with the “No child node found” error or
  2. Using he AppLayout method setContent which works perfectly except I haven’t figured out how to get authentication using @Preauthorize to work.

Code that works:
menuBar.addItem(“Blog”, e → setContent(new BlogContent()));

@PreAuthorize(“hasRole(‘USER’)”) which at this stage doesn’t try and authorize the user. That I figure out later.

So not using anchor and using setContent in my Application router layout can now be called any amount of times with no “Assertion error: No child node found with id …”

setContent version repeatedly works whereas the anchor fails.

I’ll keep looking at this issue and put some more time into it. Obviously I’d like version 2 to work with @PreAuthorize,