vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
603 stars 165 forks source link

Native image compilation fails #16307

Closed tarekoraby closed 1 year ago

tarekoraby commented 1 year ago

Description of the bug

Building a native image fails with the following error:

[INFO] --- maven-jar-plugin:3.3.0:jar (default-jar) @ spring-skeleton ---
[INFO] Building jar: C:\skeleton-starter-flow-spring-24\skeleton-starter-flow-spring-24\target\spring-skeleton-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:3.0.4:repackage (repackage) @ spring-skeleton ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] <<< native-maven-plugin:0.9.20:compile (default-cli) < package @ spring-skeleton <<<
[INFO]
[INFO]
[INFO] --- native-maven-plugin:0.9.20:compile (default-cli) @ spring-skeleton ---
[INFO] Found GraalVM installation from JAVA_HOME variable.
[INFO] Downloaded GraalVM reachability metadata repository from file:/C:/Users/Tarek%20Oraby/.m2/repository/org/graalvm/buildtools/graalvm-reachability-metadata/0.9.20/graalvm-reachability-metadata-0.9.20-repository.zip
[INFO] [graalvm reachability metadata repository for ch.qos.logback:logback-classic:1.4.5]: Configuration directory not found. Trying latest version.
[INFO] [graalvm reachability metadata repository for ch.qos.logback:logback-classic:1.4.5]: Configuration directory is ch.qos.logback\logback-classic\1.4.1
[INFO] [graalvm reachability metadata repository for org.apache.tomcat.embed:tomcat-embed-core:10.1.5]: Configuration directory not found. Trying latest version.
[INFO] [graalvm reachability metadata repository for org.apache.tomcat.embed:tomcat-embed-core:10.1.5]: Configuration directory is org.apache.tomcat.embed\tomcat-embed-core\10.0.20
[INFO] [graalvm reachability metadata repository for net.java.dev.jna:jna:5.12.1]: Configuration directory not found. Trying latest version.
[INFO] [graalvm reachability metadata repository for net.java.dev.jna:jna:5.12.1]: Configuration directory is net.java.dev.jna\jna\5.8.0
[INFO] [graalvm reachability metadata repository for org.jboss.logging:jboss-logging:3.5.0.Final]: Configuration directory is org.jboss.logging\jboss-logging\3.5.0.Final
[INFO] [graalvm reachability metadata repository for org.hibernate.validator:hibernate-validator:8.0.0.Final]: Configuration directory not found. Trying latest version.
[INFO] [graalvm reachability metadata repository for org.hibernate.validator:hibernate-validator:8.0.0.Final]: Configuration directory is org.hibernate.validator\hibernate-validator\7.0.4.Final
[INFO] Executing: C:\Program Files\graalvm-ce-java19-22.3.0\bin\native-image.cmd @target\tmp\native-image-3343143352888285618.args
Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <> at index 3: C:\skeleton-starter-flow-spring-24\skeleton-starter-flow-spring-24\target\classes
        at java.base@19.0.1/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
        at java.base@19.0.1/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
        at java.base@19.0.1/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
        at java.base@19.0.1/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
        at java.base@19.0.1/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:232)
        at java.base@19.0.1/java.nio.file.Path.of(Path.java:147)
        at java.base@19.0.1/java.nio.file.Paths.get(Paths.java:69)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.ClasspathUtils.stringToClasspath(ClasspathUtils.java:52)
        at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.addCustomImageClasspath(NativeImage.java:1582)
        at org.graalvm.nativeimage.driver/com.oracle.svm.driver.DefaultOptionHandler.processClasspathArgs(DefaultOptionHandler.java:417)
        at org.graalvm.nativeimage.driver/com.oracle.svm.driver.DefaultOptionHandler.consume(DefaultOptionHandler.java:69)
        at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage$NativeImageArgsProcessor.apply(NativeImage.java:1512)
        at org.graalvm.nativeimage.driver/com.oracle.svm.driver.DefaultOptionHandler.consume(DefaultOptionHandler.java:204)
        at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage$NativeImageArgsProcessor.apply(NativeImage.java:1512)
        at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.processNativeImageArgs(NativeImage.java:1770)
        at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.completeImageBuild(NativeImage.java:959)
        at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.build(NativeImage.java:1417)
        at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1387)
        at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.main(NativeImage.java:1374)

Expected behavior

It works

Minimal reproducible example

Versions

Artur- commented 1 year ago

Probaly graalvm is not used. Maven uses JAVA_HOME, not what you have in PATH

tarekoraby commented 1 year ago

Yes, you are right. After updating JAVA_HOME, I'm past the original error. I get a new error though after that (updated the description.

Artur- commented 1 year ago

Now it looks like a graalvm problem with no mentions of Hilla. What is the string passed to NativeImage.addCustomImageClasspath?

tarekoraby commented 1 year ago

Why does Hilla have anything to do with it? It's a Flow project.

What is the string passed to NativeImage.addCustomImageClasspath?

How to find out?

Artur- commented 1 year ago

Run the maven target in a debugger in an IDE

tarekoraby commented 1 year ago

I did, but I see nothing. Shouldn't I need to put a breakpoint NativeImage.addCustomImageClasspath, which I cannot?

Artur- commented 1 year ago

You probably need the GraalVM sources for that..

Artur- commented 1 year ago

The other option would be a InvalidPathException exception breakpoint

tarekoraby commented 1 year ago

Nope, no debugging is activated from InvalidPathException or WindowsPathParser.normalize.

mcollovati commented 1 year ago

It seems like an issue in GraalVM, that seems to have been fixed in version 23.x

https://github.com/graalvm/native-build-tools/issues/318 https://github.com/oracle/graal/pull/5725

mcollovati commented 1 year ago

@tarekoraby Did you managed to check if the issue is still valid with GraalVM 23.x?

tarekoraby commented 1 year ago

With GraalVM 20.0.1+9.1 and Vaadin 24.1, I'm past the first error. But now I get another error:

...
...
...
[INFO] Found GraalVM installation from JAVA_HOME variable.
[INFO] Downloaded GraalVM reachability metadata repository from file:/C:/Users/Tarek%20Oraby/.m2/repository/org/graalvm/buildtools/graalvm-reachability-metadata/0.9.22/graalvm-reachability-metadata-0.9.22-repository.zip
[INFO] [graalvm reachability metadata repository for net.java.dev.jna:jna:5.13.0]: Configuration directory not found. Trying latest version.
[INFO] [graalvm reachability metadata repository for net.java.dev.jna:jna:5.13.0]: Configuration directory is net.java.dev.jna\jna\5.8.0
[INFO] [graalvm reachability metadata repository for org.jboss.logging:jboss-logging:3.5.0.Final]: Configuration directory is org.jboss.logging\jboss-logging\3.5.0.Final
[INFO] [graalvm reachability metadata repository for org.hibernate.validator:hibernate-validator:8.0.0.Final]: Configuration directory not found. Trying latest version.
[INFO] [graalvm reachability metadata repository for org.hibernate.validator:hibernate-validator:8.0.0.Final]: Latest version not found!
[INFO] [graalvm reachability metadata repository for org.hibernate.validator:hibernate-validator:8.0.0.Final]: missing.
[INFO] [graalvm reachability metadata repository for org.hibernate.validator:hibernate-validator:8.0.0.Final]: Configuration directory not found. Trying latest version.
[INFO] [graalvm reachability metadata repository for org.hibernate.validator:hibernate-validator:8.0.0.Final]: Configuration directory is org.hibernate.validator\hibernate-validator\7.0.4.Final
[INFO] [graalvm reachability metadata repository for org.apache.tomcat.embed:tomcat-embed-core:10.1.8]: Configuration directory not found. Trying latest version.
[INFO] [graalvm reachability metadata repository for org.apache.tomcat.embed:tomcat-embed-core:10.1.8]: Configuration directory is org.apache.tomcat.embed\tomcat-embed-core\10.0.20
[INFO] [graalvm reachability metadata repository for ch.qos.logback:logback-classic:1.4.7]: Configuration directory not found. Trying latest version.
[INFO] [graalvm reachability metadata repository for ch.qos.logback:logback-classic:1.4.7]: Configuration directory is ch.qos.logback\logback-classic\1.4.1
[INFO] Executing: C:\Program Files\graalvm-jdk-20.0.1+9.1\bin\native-image.cmd @target\tmp\native-image-15258744494737847415.args
========================================================================================================================
GraalVM Native Image: Generating 'spring-skeleton' (executable)...
========================================================================================================================
Warning: Could not resolve class org.jboss.logmanager.LogManager for reflection configuration. Reason: java.lang.ClassNotFoundException: org.jboss.logmanager.LogManager.
Warning: Could not resolve class com.sun.el.ExpressionFactoryImpl for reflection configuration. Reason: java.lang.ClassNotFoundException: com.sun.el.ExpressionFactoryImpl.
Warning: Could not resolve class groovy.grape.GrabAnnotationTransformation for reflection configuration. Reason: java.lang.ClassNotFoundException: groovy.grape.GrabAnnotationTransformation.
Warning: Could not resolve class groovy.lang.Script for reflection configuration. Reason: java.lang.ClassNotFoundException: groovy.lang.Script.
Warning: Could not resolve class groovy.lang.Script for reflection configuration. Reason: java.lang.ClassNotFoundException: groovy.lang.Script.
Warning: Could not resolve class groovyjarjarantlr.CommonToken for reflection configuration. Reason: java.lang.ClassNotFoundException: groovyjarjarantlr.CommonToken.
Warning: Could not resolve class jakarta.persistence.Persistence for reflection configuration. Reason: java.lang.ClassNotFoundException: jakarta.persistence.Persistence.
Warning: Could not resolve class javafx.beans.value.ObservableValue for reflection configuration. Reason: java.lang.ClassNotFoundException: javafx.beans.value.ObservableValue.
Warning: Could not resolve class javax.money.MonetaryAmount for reflection configuration. Reason: java.lang.ClassNotFoundException: javax.money.MonetaryAmount.
Warning: Could not resolve class org.codehaus.groovy.antlr.GroovySourceAST for reflection configuration. Reason: java.lang.ClassNotFoundException: org.codehaus.groovy.antlr.GroovySourceAST.
Warning: Could not resolve class org.codehaus.groovy.ast.builder.AstBuilderTransformation for reflection configuration. Reason: java.lang.ClassNotFoundException: org.codehaus.groovy.ast.builder.AstBuilderTransformation.
Warning: Could not resolve class org.codehaus.groovy.runtime.ScriptBytecodeAdapter for reflection configuration. Reason: java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.ScriptBytecodeAdapter.
Warning: Could not resolve class org.glassfish.expressly.ValueExpressionImpl for reflection configuration. Reason: java.lang.ClassNotFoundException: org.glassfish.expressly.ValueExpressionImpl.
Warning: Could not resolve class org.glassfish.expressly.parser.AstValue for reflection configuration. Reason: java.lang.ClassNotFoundException: org.glassfish.expressly.parser.AstValue.
Warning: Could not resolve class org.joda.time.ReadableInstant for reflection configuration. Reason: java.lang.ClassNotFoundException: org.joda.time.ReadableInstant.
Warning: Could not register method org.hibernate.validator.internal.constraintvalidators.bv.time.future.FutureValidatorForReadablePartial.<init>() for reflection. Reason: java.lang.NoClassDefFoundError: org/joda/time/ReadableInstant.
Warning: Could not register method org.hibernate.validator.internal.constraintvalidators.bv.time.futureorpresent.FutureOrPresentValidatorForReadablePartial.<init>() for reflection. Reason: java.lang.NoClassDefFoundError: org/joda/time/ReadableInstant.
Warning: Could not register method org.hibernate.validator.internal.constraintvalidators.bv.time.past.PastValidatorForReadablePartial.<init>() for reflection. Reason: java.lang.NoClassDefFoundError: org/joda/time/ReadableInstant.
Warning: Could not register method org.hibernate.validator.internal.constraintvalidators.bv.time.pastorpresent.PastOrPresentValidatorForReadablePartial.<init>() for reflection. Reason: java.lang.NoClassDefFoundError: org/joda/time/ReadableInstant.
Warning: Could not resolve class org.springframework.security.web.csrf.CsrfTokenRequestAttributeHandler$SupplierCsrfToken for reflection configuration. Reason: java.lang.ClassNotFoundException: org.springframework.security.web.csrf.CsrfTokenRequestAttributeHandler$SupplierCsrfToken.
[1/8] Initializing...                                                                                   (12,1s @ 0,21GB)
 Java version: 20.0.1+9, vendor version: Oracle GraalVM 20.0.1+9.1
 Graal compiler: optimization level: 2, target machine: x86-64-v3, PGO: ML-inferred
 C compiler: cl.exe (microsoft, x64, 19.36.32534)
 Garbage collector: Serial GC (max heap size: 80% of RAM)
 1 user-specific feature(s)
 - org.springframework.aot.nativex.feature.PreComputeFieldFeature
Field org.springframework.core.NativeDetector#imageCode set to true at build time
Field org.springframework.boot.logging.log4j2.Log4J2LoggingSystem$Factory#PRESENT set to false at build time
Field org.springframework.http.converter.json.Jackson2ObjectMapperBuilder#jackson2XmlPresent set to false at build time
Field org.springframework.boot.logging.logback.LogbackLoggingSystem$Factory#PRESENT set to true at build time
Field org.springframework.cglib.core.AbstractClassGenerator#imageCode set to true at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#romePresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jaxb2Present set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2Present set to true at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2XmlPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2SmilePresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2CborPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#gsonPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jsonbPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#kotlinSerializationCborPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#kotlinSerializationJsonPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#kotlinSerializationProtobufPresent set to false at build time
Field org.springframework.core.KotlinDetector#kotlinPresent set to false at build time
Field org.springframework.core.KotlinDetector#kotlinReflectPresent set to false at build time
Field org.springframework.web.servlet.view.InternalResourceViewResolver#jstlPresent set to false at build time
Field org.springframework.format.support.DefaultFormattingConversionService#jsr354Present set to false at build time
Field org.springframework.web.context.support.WebApplicationContextUtils#jsfPresent set to false at build time
Field org.springframework.web.client.RestTemplate#romePresent set to false at build time
Field org.springframework.web.client.RestTemplate#jaxb2Present set to false at build time
Field org.springframework.web.client.RestTemplate#jackson2Present set to true at build time
Field org.springframework.web.client.RestTemplate#jackson2XmlPresent set to false at build time
Field org.springframework.web.client.RestTemplate#jackson2SmilePresent set to false at build time
Field org.springframework.web.client.RestTemplate#jackson2CborPresent set to false at build time
Field org.springframework.web.client.RestTemplate#gsonPresent set to false at build time
Field org.springframework.web.client.RestTemplate#jsonbPresent set to false at build time
Field org.springframework.web.client.RestTemplate#kotlinSerializationCborPresent set to false at build time
Field org.springframework.web.client.RestTemplate#kotlinSerializationJsonPresent set to false at build time
Field org.springframework.web.client.RestTemplate#kotlinSerializationProtobufPresent set to false at build time
Field org.springframework.boot.logging.java.JavaLoggingSystem$Factory#PRESENT set to true at build time
Field org.springframework.web.context.support.StandardServletEnvironment#jndiPresent set to true at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jaxb2Present set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jackson2Present set to true at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jackson2XmlPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jackson2SmilePresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#gsonPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jsonbPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#kotlinSerializationCborPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#kotlinSerializationJsonPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#kotlinSerializationProtobufPresent set to false at build time
Field org.springframework.boot.autoconfigure.web.format.WebConversionService#JSR_354_PRESENT set to false at build time
Field org.springframework.boot.logging.logback.LogbackLoggingSystemProperties#JBOSS_LOGGING_PRESENT set to true at build time
Field org.springframework.web.context.request.RequestContextHolder#jsfPresent set to false at build time
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
Field org.springframework.web.servlet.mvc.method.annotation.ReactiveTypeHandler#isContextPropagationPresent set to false at build time
Field org.springframework.core.ReactiveAdapterRegistry#reactorPresent set to false at build time
Field org.springframework.core.ReactiveAdapterRegistry#rxjava3Present set to false at build time
Field org.springframework.core.ReactiveAdapterRegistry#kotlinCoroutinesPresent set to false at build time
Field org.springframework.core.ReactiveAdapterRegistry#mutinyPresent set to false at build time
Field org.springframework.context.event.ApplicationListenerMethodAdapter#reactiveStreamsPresent set to false at build time
Field org.springframework.web.servlet.support.RequestContext#jstlPresent set to false at build time
[2/8] Performing analysis...  []                                                                        (40,6s @ 2,52GB)
  21 954 (89,64%) of 24 491 types reachable
  36 215 (65,83%) of 55 010 fields reachable
 116 285 (66,35%) of 175 265 methods reachable
   6 605 types, 1 266 fields, and 10 046 methods registered for reflection
       4 native libraries: crypt32, ncrypt, psapi, winhttp

Error: Classes that should be initialized at run time got initialized during image building:
 org.apache.commons.logging.LogFactory was unintentionally initialized at build time. To see why org.apache.commons.logging.LogFactory got initialized use --trace-class-initialization=org.apache.commons.logging.LogFactory
To see how the classes got initialized, use --trace-class-initialization=org.apache.commons.logging.LogFactory
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
------------------------------------------------------------------------------------------------------------------------
                        4,0s (7,3% of total time) in 49 GCs | Peak RSS: 4,54GB | CPU load: 6,61
========================================================================================================================
Finished generating 'spring-skeleton' in 53,1s.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:12 min
[INFO] Finished at: 2023-06-15T16:33:01+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.22:compile (default-cli) on project spring-skeleton: Execution of C:\Program Files\graalvm-jdk-20.0.1+9.1\bin\native-image.cmd @target\tmp\native-image-15258744494737847415.args returned non-zero result -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
mcollovati commented 1 year ago

According to this issue the new problem seems to happen with Spring Boot 3.1.0. It seems like the culprit is the commons-logging dependency transitively imported through flow-server -> httpclient.

Adding an exclusion for commons-logging in vaadin-spring-boot-starter make the native compilation work, but then I got an error at runtime. But this is not related to commons-logging as it complains about not founding org.springframework.boot.devtools.restart.RestartScopeInitializer class.

mcollovati commented 1 year ago

Also the RestartScopeInitializer seems a know issue for Spring Boot 3.1

https://github.com/spring-projects/spring-boot/issues/35853

mcollovati commented 1 year ago

Applied the following workarounds

but then got another runtime error

Caused by: java.lang.IllegalStateException: Parent resource of [file:///resources!/org/vaadin/example/Application$$SpringCGLIB$$0.class] not found in the resources!
    at com.vaadin.flow.spring.VaadinServletContextInitializer$CustomResourceLoader.collectResources(VaadinServletContextInitializer.java:847) ~[na:na]
    at com.vaadin.flow.spring.VaadinServletContextInitializer$CustomResourceLoader.getResources(VaadinServletContextInitializer.java:817) ~[na:na]
    at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:422) ~[spring-skeleton:6.0.9]
    at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:317) ~[spring-skeleton:6.0.9]
    at java.base@17.0.5/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[na:na]
    at java.base@17.0.5/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) ~[na:na]
    at java.base@17.0.5/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[spring-skeleton:na]
    at java.base@17.0.5/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[spring-skeleton:na]
    at java.base@17.0.5/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) ~[spring-skeleton:na]
    at java.base@17.0.5/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[spring-skeleton:na]
    at java.base@17.0.5/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[spring-skeleton:na]
    at com.vaadin.flow.spring.VaadinServletContextInitializer$VaadinAppShellContextListener.failFastContextInitialized(VaadinServletContextInitializer.java:556) ~[na:na]
    at com.vaadin.flow.spring.VaadinServletContextInitializer$FailFastServletContextListener.contextInitialized(VaadinServletContextInitializer.java:187) ~[spring-skeleton:na]
    ... 41 common frames omitted
mcollovati commented 1 year ago

Vaadin 24.2-SNAPSHOT does not have the transitive dependency to commons-logging anymore, but I can still see the above runtime error.

mcollovati commented 1 year ago

After getting rid of the resource error, there's another issue at runtime related to PWA icons generation

java.lang.NoSuchMethodError: sun.java2d.Disposer.addRecord(Ljava/lang/Object;JJ)V
    at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1259) ~[na:na]
    at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1244) ~[na:na]
    at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions.GetStaticMethodID(JNIFunctions.java:413) ~[na:na]
    at java.desktop@17.0.5/sun.java2d.Disposer.initIDs(Disposer.java) ~[na:na]
    at java.desktop@17.0.5/sun.java2d.Disposer.<clinit>(Disposer.java:72) ~[na:na]
    at java.desktop@17.0.5/javax.imageio.stream.FileCacheImageInputStream.<init>(FileCacheImageInputStream.java:114) ~[na:na]
    at java.desktop@17.0.5/com.sun.imageio.spi.InputStreamImageInputStreamSpi.createInputStreamInstance(InputStreamImageInputStreamSpi.java:69) ~[na:na]
    at java.desktop@17.0.5/javax.imageio.ImageIO.createImageInputStream(ImageIO.java:359) ~[na:na]
    at java.desktop@17.0.5/javax.imageio.ImageIO.read(ImageIO.java:1361) ~[na:na]
    at com.vaadin.flow.server.PwaRegistry.getBaseImage(PwaRegistry.java:404) ~[na:na]
    at com.vaadin.flow.server.PwaRegistry.initializeResources(PwaRegistry.java:128) ~[na:na]
    at com.vaadin.flow.server.PwaRegistry.<init>(PwaRegistry.java:108) ~[na:na]
    at com.vaadin.flow.server.PwaRegistry.getInstance(PwaRegistry.java:335) ~[na:na]
    at java.base@17.0.5/java.util.Optional.map(Optional.java:260) ~[spring-skeleton:na]
    at com.vaadin.flow.server.VaadinServletService.getPwaRegistry(VaadinServletService.java:215) ~[spring-skeleton:24.2-SNAPSHOT]
    at com.vaadin.flow.server.VaadinService.lambda$createRequestHandlers$20741bb$1(VaadinService.java:325) ~[spring-skeleton:24.2-SNAPSHOT]
    at com.vaadin.flow.server.communication.PwaHandler.handleRequest(PwaHandler.java:134) ~[na:na]
mcollovati commented 1 year ago

Had a quick chat with @marcushellberg, and it seems like that the icon generation is a known issue

vaadin-bot commented 1 year ago

This ticket/PR has been released with Vaadin 24.0.9.

vaadin-bot commented 1 year ago

This ticket/PR has been released with Vaadin 24.2.0.alpha2 and is also targeting the upcoming stable 24.2.0 version.

PavelBortnovskyi commented 10 months ago

After getting rid of the resource error, there's another issue at runtime related to PWA icons generation

java.lang.NoSuchMethodError: sun.java2d.Disposer.addRecord(Ljava/lang/Object;JJ)V
  at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1259) ~[na:na]
  at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1244) ~[na:na]
  at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions.GetStaticMethodID(JNIFunctions.java:413) ~[na:na]
  at java.desktop@17.0.5/sun.java2d.Disposer.initIDs(Disposer.java) ~[na:na]
  at java.desktop@17.0.5/sun.java2d.Disposer.<clinit>(Disposer.java:72) ~[na:na]
  at java.desktop@17.0.5/javax.imageio.stream.FileCacheImageInputStream.<init>(FileCacheImageInputStream.java:114) ~[na:na]
  at java.desktop@17.0.5/com.sun.imageio.spi.InputStreamImageInputStreamSpi.createInputStreamInstance(InputStreamImageInputStreamSpi.java:69) ~[na:na]
  at java.desktop@17.0.5/javax.imageio.ImageIO.createImageInputStream(ImageIO.java:359) ~[na:na]
  at java.desktop@17.0.5/javax.imageio.ImageIO.read(ImageIO.java:1361) ~[na:na]
  at com.vaadin.flow.server.PwaRegistry.getBaseImage(PwaRegistry.java:404) ~[na:na]
  at com.vaadin.flow.server.PwaRegistry.initializeResources(PwaRegistry.java:128) ~[na:na]
  at com.vaadin.flow.server.PwaRegistry.<init>(PwaRegistry.java:108) ~[na:na]
  at com.vaadin.flow.server.PwaRegistry.getInstance(PwaRegistry.java:335) ~[na:na]
  at java.base@17.0.5/java.util.Optional.map(Optional.java:260) ~[spring-skeleton:na]
  at com.vaadin.flow.server.VaadinServletService.getPwaRegistry(VaadinServletService.java:215) ~[spring-skeleton:24.2-SNAPSHOT]
  at com.vaadin.flow.server.VaadinService.lambda$createRequestHandlers$20741bb$1(VaadinService.java:325) ~[spring-skeleton:24.2-SNAPSHOT]
  at com.vaadin.flow.server.communication.PwaHandler.handleRequest(PwaHandler.java:134) ~[na:na]

Hi. How it was solved? I got similar error in my native image. Need help with it.

javier-godoy commented 5 months ago

@PavelBortnovskyi

Running the tracing agent produce the following JNI hint (jni-config.json)

{
  "name":"sun.java2d.Disposer",
  "methods":[{"name":"addRecord","parameterTypes":["java.lang.Object","long","long"] }]
}
PavelBortnovskyi commented 5 months ago

@PavelBortnovskyi

Running the tracing agent produce the following JNI hint (jni-config.json)

{
  "name":"sun.java2d.Disposer",
  "methods":[{"name":"addRecord","parameterTypes":["java.lang.Object","long","long"] }]
}

I have this in my JNI config: { "name": "sun.java2d.Disposer", "allDeclaredConstructors": true, "allPublicConstructors": true, "allDeclaredMethods": true, "allPublicMethods": true }

But I facing problem with tracing agent. It blocking folder to write by itself by .lock file. How to fix this behavior?