Gradle Sprintboot Starter Project build problem

I am a complete newbie to Vaadin. I wanted to evaluate and adopt to Vaadin primarily because of the possibililty of developing the entire PWA with Java (server-side components only). I have a gradle multi-project (also on springboot 2) that implements and expose all APIs to front end applications. For that reason, I wanted to start with Vaadin on gradle with springboot as well.

I used base-starter-spring-gradle to jumpstart my evaluation work. with no changes, when i run the project with gradle bootRun, everything works well and as expected.

I wanted to test running as bootJar (so I can ship this own process/VM). So I follow the instruction on github readme with the command gradle build && java -jar build/libs/base-starter-spring-gradle*.jar. The gradle build states successful however when springboot starts up, I find the following errors on the console.

Failed to find the following imports in the `node_modules` tree:
      - @vaadin/flow-frontend/datepickerConnector.js
      - @vaadin/flow-frontend/contextMenuConnector-es6.js
      - @vaadin/flow-frontend/comboBoxConnector.js
      - @vaadin/flow-frontend/ironListConnector.js
      - @vaadin/flow-frontend/timepickerConnector.js
      - @vaadin/flow-frontend/comboBoxConnector-es6.js
      - @vaadin/flow-frontend/ironListStyles.js
      - @vaadin/flow-frontend/selectConnector.js
      - @vaadin/flow-frontend/vaadin-big-decimal-field.js
      - @vaadin/flow-frontend/contextMenuConnector.js
      - @vaadin/flow-frontend/gridConnector.js
      - @vaadin/flow-frontend/flow-component-renderer.js
      - @vaadin/flow-frontend/gridConnector-es6.js
      - @vaadin/flow-frontend/dndConnector-es6.js
      - @vaadin/flow-frontend/ironListConnector-es6.js
      - @vaadin/flow-frontend/menubarConnector.js
      - @vaadin/flow-frontend/vaadin-grid-flow-selection-column.js
      - @vaadin/flow-frontend/dndConnector.js
  If the build fails, check that npm packages are installed.

And then repeated print @ ../target/frontend/generated-flow-imports.js for each component listed above. But the server starts and the browser display appears broken (as if no css is connected) and an overlay box is displayed with message…

Webpack Error
Webpack build failed with errors:
ERROR in ../target/frontend/generated-flow-imports.js

I notice a hint to enable production mode for standalone bootjar and so I add -PproductionMode to the build and execute I used above. This time the buildFrontend fails with message Unable to locate a required class using custom class loader. Enabling stacktace in gradle, I find the root cause to be the following…

Caused by: java.lang.ClassNotFoundException: com.vaadin.flow.component.WebComponentExporterFactory
        at com.vaadin.flow.server.scanner.ReflectionsClassFinder.loadClass(
        at com.vaadin.flow.server.frontend.scanner.ClassFinder$CachedClassFinder.loadClass(
        at com.vaadin.flow.server.frontend.scanner.ClassFinder.getSubTypesOf(
        at com.vaadin.flow.server.frontend.FrontendWebComponentGenerator.generateWebComponents(
        ... 100 more

Note: I did pore over google and vaadin forum for this situation. I did find a couple issues discussed about the missing webpack modules but they were all about maven plugin issues and I do not have such problems in my gradle build script. The starter project does not use RC or snapshot artefacts. Also, there is no error regarding the vaadin plugin applied to the project.

Many thanks in advance for any help resolving the issue. Would encourage me in continuing with Vaadin.

Thanks and best regards,

Hi, it looks like you’re using Vaadin 14 in the npm mode. In such case you will need to use the Vaadin Gradle plugin:

Example Spring app is located here:

EDIT: Sorry, it sounds like you actually are using the correct starter. I’ll analyze the issue further and I’ll post more.

Apologies, the project was broken since the Vaadin Gradle plugin was 0.7.0 but Vaadin was an older 14.1.23. I’ve fixed this, and now everything should work properly.

Regarding gradle build && java -jar build/libs/base-starter-spring-gradle*.jar: the project is built in development mode and is not supposed to be launched like that; please use ./gradlew build bootRun instead. However, I’ve tried with the newest fixes and now even the command above should work properly.

Also please make sure to use -Pvaadin.productionMode and not just -PproductionMode.

Thank you @Martin for a quick response and solution. I picked up the diff from github. And yes, the vaadin. prefix for productionMode did the trick. The starter project works well in the CI mode. I can now add some feature screens to check out the app development. :slight_smile: