Production build faild

Hi,

This is a follow-up post for https://vaadin.com/forum/t/urgent-production-build-failed/178117: sometimes the production build is marked as successful, but after starting the 24.7 app, the following error occurs for the first visible view, the login view:

The component class de.hub28.hwg.isplaner.security.LoginView includes '@vaadin/login/src/vaadin-login-overlay.js' but this file was not included when creating the production bundle. The component will not work properly. Check that you have a reference to the component and that you are not using it only through reflection. If needed add a @Uses(LoginView.class) where it is used.

Today I was able to isolate the issue. I make two subsequent Maven build runs, with two different log files, using the command:

mvn clean -Dmaven.test.skip -Pproduction package -Djarfile=isplaner -Dorg.slf4j.simpleLogger.showDateTime=false -X >maven.log && java -jar target/isplaner.jar --spring.profiles.active=default

For the failed run, it seems that my own Java classes are not collected/found by the Vaadin Maven plugin. The log files differ in the output of:

[INFO] --- vaadin:24.7.7:prepare-frontend (default) @ isplaner ---
List of npm dependencies found in the project:

Only the log file for the successful variant shows my own project files found, something like this:

[INFO] --- vaadin:24.7.7:prepare-frontend (default) @ isplaner ---
List of npm dependencies found in the project:
- @vaadin/app-layout 24.7.8 de.hub28.hwg.isplaner.MainLayout
- @vaadin/login 24.7.8 de.hub28.hwg.isplaner.security.LoginView

The log file for the failed version is missing those lines, contains only something like

- @vaadin/accordion 24.7.8 com.vaadin.flow.component.accordion.Accordion

I have a MVE (minimal viable example) that makes the issue somewhat reproducible.
DM me for providing a zip with the MVE.

Any suggestions, why sometimes the project files are not handled ?

Kind regards
Dominik

After providing the MVE and a very sucessful conversation with @marcoc_753 we found the following solution:

If the pom.xml contains both plugins, vaadin-maven-plugin and maven-compiler-plugin then the order is important. maven-compiler-plugin must BEFORE vaadin-maven-plugin because otherwise build-frontend is executed before the maven compiler plugin, so the Vaadin bytecode scanner cannot scan the project classes and found the frontend dependencies needed for the production bundle.

Maybe this should find a way into the Vaadin documentation.

So thanks to @marcoc_753

Kind regards
Dominik

Thanks @todo42 for taking the time to create the MVE.

Here’s the issue on the documentation repository Highlight that `vaadin-maven-plugin` must always be defined after `maven-compiler-plugin` · Issue #4432 · vaadin/docs · GitHub

1 Like