vaadin / quarkus

An extension to Quarkus to support Vaadin Flow
Apache License 2.0
28 stars 3 forks source link

Native build fails because of missing DevModeStartupListener #158

Open mcollovati opened 1 month ago

mcollovati commented 1 month ago

When building a native image for a Quarkus application using the Vaadin add-on, an error occurs during native compilation because DevModeStartupListener class is missing.

Caused by: java.lang.ClassNotFoundException: com.vaadin.base.devserver.startup.DevModeStartupListener
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageClassLoader.loadClass(NativeImageClassLoader.java:637)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:529)
        at java.base/java.lang.Class.forName(Class.java:508)
        at com.vaadin.base.devserver.startup.DevModeStartupListener_Bean.<init>(Unknown Source)
        at io.quarkus.arc.setup.Default_ComponentsProvider.addBeans1(Unknown Source)
        at io.quarkus.arc.setup.Default_ComponentsProvider.getComponents(Unknown Source)

The class is contained in the vaadin-dev-server artifact, that should be excluded for production and native builds. However, all artifact classes are present in the vaadin-core-jandex index, so they are discovered during native build, but not available on classpath.

The vaadin-dev-server artifact classes (and probably other dev-mode dependencies) should be removed from the vaadin-core-jandex index, and put into a new index (e.g. vaadin-dev-jandex) that can be excluded for production and native builds, or it can be a transitive dependency of the vaadin-dev artifact, so just excluding that one should be enough.