webcomponents not loaded

Hello everyone,
I’m at step 3 of the tutorial for the migration of my app from vaadin 8 to 14. At the moment the v8 responds at http://localhost:8080/ATMProject/v8/ and the v14 at http://localhost:8080/ATMProject/. I’m on 14.3.5. When I load the v8 servlet all is fine but the v14 doesn’t load any of the webcomponents, the result is down here:

In the console this messages appear:

DEBUG [default task-2]
 (UIInternals.java:879) - Fallback chunk is not available, skipping fallback dependencies load
DEBUG [default task-2]
 (UidlWriter.java:162) - * Creating response to client
DEBUG [default task-2]
 (UIInternals.java:879) - Fallback chunk is not available, skipping fallback dependencies load
DEBUG [default task-2]
 (UIInternals.java:879) - Fallback chunk is not available, skipping fallback dependencies load
DEBUG [default task-2]
 (UIInternals.java:879) - Fallback chunk is not available, skipping fallback dependencies load
DEBUG [default task-2]
 (UIInternals.java:879) - Fallback chunk is not available, skipping fallback dependencies load
DEBUG [default task-2]
 (UIInternals.java:879) - Fallback chunk is not available, skipping fallback dependencies load
DEBUG [default task-2]
 (UIInternals.java:879) - Fallback chunk is not available, skipping fallback dependencies load
DEBUG [default task-2]
 (UIInternals.java:879) - Fallback chunk is not available, skipping fallback dependencies load
DEBUG [default task-2]
 (UIInternals.java:879) - Fallback chunk is not available, skipping fallback dependencies load
DEBUG [default task-2]
 (UIInternals.java:879) - Fallback chunk is not available, skipping fallback dependencies load
DEBUG [default task-2]
 (UIInternals.java:879) - Fallback chunk is not available, skipping fallback dependencies load
DEBUG [default task-2]
 (BootstrapHandler.java:792) - Initial UIDL: [object Object]

DEBUG [default task-2]
 (BrowserLiveReloadImpl.java:77) - Class org.hotswap.agent.plugin.vaadin.VaadinIntegration not found, excluding HOTSWAP_AGENT
DEBUG [default task-2]
 (BrowserLiveReloadImpl.java:77) - Class com.vaadin.flow.server.jrebel.JRebelInitializer not found, excluding JREBEL
DEBUG [default task-2]
 (BrowserLiveReloadImpl.java:77) - Class com.vaadin.flow.spring.SpringServlet not found, excluding SPRING_BOOT_DEVTOOLS
DEBUG [default task-2]
 (VaadinService.java:1332) - Closing inactive UI #3 in session jLbZSguQOlWNTuf0kaBCEMs-k1Af4ysvRLi2lIwm
DEBUG [default task-2]
 (VaadinService.java:1316) - Removing closed UI 3
 INFO [default task-2]
 (VaadinServlet.java:817) - Requested resource 
[/VAADIN/build/webcomponentsjs/webcomponents-loader.js] not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.
 INFO [default task-2]
 (VaadinServlet.java:817) - Requested resource 
[/VAADIN/build/vaadin-bundle-a0b0667b27ca27849008.cache.js] not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.
DEBUG [default task-2]
 (UidlWriter.java:162) - * Creating response to client

I tried to change version of vaadin 14 in the pom.xml, change webserver (TomCat 9 or Wildfly 20) and to remove node_modules folder and the .json/.js files but nothing works…

This is the LoginView class:

package eu.bToCode.application;

import java.io.Serializable;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.Html;
import com.vaadin.flow.component.Key;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.button.ButtonVariant;
import com.vaadin.flow.component.formlayout.FormLayout;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.FlexLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.PasswordField;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.router.Route;

@Route("login")
public class LoginView extends FlexLayout {
    private TextField username;
    private PasswordField password;
    private Button login;
    private Button forgotPassword;

    public LoginView() {
        buildUI();
        username.focus();
    }

    private void buildUI() {
        addClassName("login-screen");

        // login form, centered in the available part of the screen
        Component loginForm = buildLoginForm();

        // layout to center login form when there is sufficient screen space
        // - see the theme for how this is made responsive for various screen
        // sizes
        VerticalLayout centeringLayout = new VerticalLayout();
        centeringLayout.setMargin(false);
        centeringLayout.setSpacing(false);
        centeringLayout.setClassName("centering-layout");
        /**
         * Setting jusitfy conentent mdoe and align items to center for the verticallayout
         * Also need to wrap the formlayout, as formlayout has align-self: stretch
         */
        centeringLayout.add(new Div(loginForm));
        centeringLayout.setJustifyContentMode(FlexComponent.JustifyContentMode.CENTER);
        centeringLayout.setDefaultHorizontalComponentAlignment(FlexComponent.Alignment.CENTER);
        /** Or use margin:auto
         * centeringLayout.add(loginForm);
         * loginForm.getElement().getStyle().set("margin", "auto");
         */


        // information text about logging in
        Div loginInformation = buildLoginInformation();

        add(centeringLayout);
        add(loginInformation);
    }

    private Component buildLoginForm() {
        FormLayout loginForm = new FormLayout();

        loginForm.addClassName("login-form");
        loginForm.setWidth("24em");

        loginForm.addFormItem(username = new TextField(null, "admin", "admin"), "Username");
        username.setWidth("15em");
        loginForm.addFormItem(password = new PasswordField(), "Password");
        password.setWidth("15em");
        Div buttons = new Div();
        buttons.setClassName("buttons");
        loginForm.add(buttons);

        buttons.add(login = new Button("Login"));
        login.setDisableOnClick(true);
        login.addClickListener(event -> {
            try {
                login();
            } finally {
                login.setEnabled(true);
            }
        });
        login.addClickShortcut(Key.ENTER).listenOn(password).allowBrowserDefault();
        loginForm.getElement()
                .addEventListener("keypress", event -> login())
                .setFilter("event.key == 'Enter'");
        login.addThemeVariants(ButtonVariant.LUMO_PRIMARY, ButtonVariant.LUMO_SUCCESS);

        buttons.add(forgotPassword = new Button("Forgot password?"));
        forgotPassword.addClickListener(e -> Notification.show("Hint: Try anything"));
        forgotPassword.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
        return loginForm;
    }

    private Div buildLoginInformation() {
        Div loginInformation = new Div();
        loginInformation.addClassName("login-information");
        Html loginInfoText = new Html(
                "<div><h1>Login Information</h1>"
                        + "Log in as &quot;admin&quot; to have full access. Log in with any other username to have read-only access. For all users, any password is fine</div>");
        loginInformation.add(loginInfoText);
        return loginInformation;
    }

    private void login() {
        if (username.getValue().equals("admin")&& password.getValue().equals("a")) {
            getUI().ifPresent(ui->ui.navigate(MainApplicationV14.class));
        } else {
            Notification.show("Please check your username and password and try again.");
            username.focus();
        }
    }

    public interface LoginListener extends Serializable {
        void loginSuccessful();
    }
}

Please can anyone help me?

Does nobody have an idea?

Hi,

Sorry for the late answer but can you share your pom.xml?

There is definitely something wrong with context mappings of the two applications

These lines are logged by Vaadin 8’s VaadinServlet

 INFO [default task-2]
 (VaadinServlet.java:817) - Requested resource 
[/VAADIN/build/webcomponentsjs/webcomponents-loader.js] not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.
 INFO [default task-2]
 (VaadinServlet.java:817) - Requested resource 
[/VAADIN/build/vaadin-bundle-a0b0667b27ca27849008.cache.js] not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.

That indicates that due some configuration issue, Vaadin 14 initialization requests are routed to Vaadin 8 Servlet instead of Vaadin 14. Hence things go wrong.

Thank you for the answers, this is my pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>eu.BToCode</groupId>
	<artifactId>ATMProject</artifactId>
	<version>1.0</version>
	<packaging>war</packaging>
	<properties>
		<maven.compiler.source>1.8</maven.compiler.source>
		<maven.compiler.target>1.8</maven.compiler.target>
		<vaadin.plugin.version>8.6.2</vaadin.plugin.version>
		<jetty.plugin.version>9.4.31.v20200723</jetty.plugin.version>
		<flow.plugin.version>2.3.5</flow.plugin.version>
		<!-- <widgetset>com.vaadin.v7.Vaadin7WidgetSet</widgetset> -->
	</properties>
	<build>
		<finalName>ATMProject</finalName>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<version>2.6</version>
				<configuration>
					<failOnMissingWebXml>false</failOnMissingWebXml>
					<!-- Exclude an unnecessary file generated by the GWT compiler. -->
					<packagingExcludes>WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes>
				</configuration>
			</plugin>
			<plugin>
				<groupId>com.vaadin</groupId>
				<artifactId>vaadin-maven-plugin</artifactId>
				<version>${vaadin.plugin.version}</version>
				<executions>
					<execution>
						<goals>
							<goal>compile-theme</goal>
							<!-- <goal>update-theme</goal> -->
							<goal>update-widgetset</goal>
							<goal>compile</goal>
							<!-- Comment out compile-theme goal to use on-the-fly theme compilation -->
						</goals>
					</execution>
				</executions>
				<configuration>
					<gwtSdkFirstInClasspath>true</gwtSdkFirstInClasspath>
					<extraJvmArgs>-Xmx1G</extraJvmArgs>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-clean-plugin</artifactId>
				<version>3.0.0</version>
				<!-- Clean up also any pre-compiled themes -->
				<configuration>
					<filesets>
						<fileset>
							<directory>src/main/webapp/VAADIN/themes</directory>
							<includes>
								<include>**/styles.css</include>
								<include>**/styles.scss.cache</include>
							</includes>
						</fileset>
					</filesets>
				</configuration>
			</plugin>
			<!-- The Jetty plugin allows us to easily test the development build by 
				running jetty:run on the command line. -->
			<plugin>
				<groupId>org.eclipse.jetty</groupId>
				<artifactId>jetty-maven-plugin</artifactId>
				<version>${jetty.plugin.version}</version>
				<configuration>
					<scanIntervalSeconds>2</scanIntervalSeconds>
				</configuration>
			</plugin>
			<plugin>
				<groupId>com.vaadin</groupId>
				<artifactId>flow-maven-plugin</artifactId>
				<version>${flow.plugin.version}</version>
				<executions>
					<execution>
						<goals>
							<goal>prepare-frontend</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
	<profiles>
		<profile>
			<!-- Production mode is activated using -Pproduction -->
			<id>production</id>
			<properties>
				<vaadin.productionMode>true</vaadin.productionMode>
			</properties>

			<dependencies>
				<dependency>
					<groupId>com.vaadin</groupId>
					<artifactId>flow-server-production-mode</artifactId>
				</dependency>
			</dependencies>

			<build>
				<plugins>
					<plugin>
						<groupId>com.vaadin</groupId>
						<artifactId>flow-maven-plugin</artifactId>
						<version>${flow.version}</version>
						<executions>
							<execution>
								<goals>
									<goal>build-frontend</goal>
								</goals>
								<phase>compile</phase>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
	<repositories>
		<repository>
			<id>central</id>
			<url>https://repo.maven.apache.org/maven2/</url>
		</repository>
		<repository>
			<id>si-nexus</id>
			<url>http://xxxxxx:8081/repository/maven-releases/</url>
		</repository>
	</repositories>
	<dependencies>
	<!--  	<dependency>
			<groupId>com.oracle</groupId>
			<artifactId>ojdbc6</artifactId>
			<version>11.2.0.4</version>
		</dependency>
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.37</version>
		</dependency>
		<dependency>
			<groupId>com.microsoft.sqlserver</groupId>
			<artifactId>mssql-jdbc</artifactId>
			<version>6.1.0.jre8</version>
		</dependency> -->
		<dependency>
			<groupId>org.postgresql</groupId>
			<artifactId>postgresql</artifactId>
			<version>9.4.1212</version>
		</dependency>
		<dependency>
			<groupId>org.apache.lucene</groupId>
			<artifactId>lucene-core</artifactId>
			<version>3.2.0</version>
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<version>3.0.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>eu.BToCode</groupId>
			<artifactId>GestioneAccessiVaadin14</artifactId>
			<version>1.0</version>
		</dependency>
		<dependency>
			<groupId>eu.BToCode</groupId>
			<artifactId>BToCodeFrameworkVaadin14</artifactId>
			<version>1.0</version>
			<scope>compile</scope>
			<exclusions>
				<exclusion>
					<artifactId>asm</artifactId>
					<groupId>asm</groupId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>eu.BToCode</groupId>
			<artifactId>UseCaseStereotypesVaadin14</artifactId>
			<version>1.0</version>
		</dependency>
	</dependencies>
</project>