Vaadin 24 - Production mode on : Error on build-frontend when packaging / Cannot invoke "java.lang.Class.isInterface()"
While application is running well when started with spring-boot:run, we cannot achieve package goal.
Following error is showing on build-frontend phase :
[ERROR] Failed to execute goal com.vaadin:vaadin-maven-plugin:24.0.5:build-frontend (default-cli) on project myproj: Could not execute build-frontend goal: Error occured during goal execution: Cannot invoke "java.lang.Class.isInterface()" because the return value of "org.reflections.Reflections.forClass(String, java.lang.ClassLoader[])" is nullPlease run Maven with the -e switch (or Gradle with the --stacktrace switch), to learn the full stack trace. -> [Help 1]
[ERROR]
POM is quite basic, with cfg :
<properties>
<java.version>17</java.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<vaadin.version>24.0.5</vaadin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
Executing goals with JDK17
Error only shows up with production profile. Works well without. I found same error report on earlier Vaadin versions, solved adding --enable-preview, but not working here with JDK17 / Vaadin24
As part of the production build, the classpath is scanned for classes for certain annotations such as @JsModule
. This is to be able to create the JavaScript bundle used in the final application.
What is done is basically:
reflections
library to find types annotated with e.g. @JsModule
@JsModule
annotations and build a JavaScript bundleStep 2 is the one that goes wrong here, and in the way that a class with a given annotation is found, but then when trying to load the class, it cannot be loaded.
As you mentioned, one problem might be that the class uses preview features and you have not enabled preview features for the production build. Another case described in https://github.com/vaadin/flow/issues/16577 is that a dependency jar compiled with a newer JDK was included.
You should be able to find the offending class by running the Maven target in an IDE in debug mode and adding a NullPointerException
breakpoint. Then it might become clear what the actual problem is.