quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.73k stars 2.67k forks source link

Compilation to native fails, when quarkus-smallrye-openapi is included #30919

Closed fedinskiy closed 1 year ago

fedinskiy commented 1 year ago

Describe the bug

I have an application, which uses quarkus-smallrye-openapi dependency. The application works flawlessly in JVM mode, but fails during Performing analysis phase in Native mode. Experimenting shows, that the app fails simply when that dependency is included in pom.

Expected behavior

App should work in both JVM and Native modes

Actual behavior

[2/7] Performing analysis...  []                                                                        (43.2s @ 1.13GB)
  11,264 (91.32%) of 12,334 classes reachable
  14,775 (57.48%) of 25,705 fields reachable
  47,410 (80.62%) of 58,807 methods reachable
     541 classes,     0 fields, and     0 methods registered for reflection

Error: java.util.concurrent.ExecutionException: com.oracle.svm.core.util.VMError$HostedError: java.lang.reflect.InvocationTargetException
com.oracle.graal.pointsto.util.AnalysisError: java.util.concurrent.ExecutionException: com.oracle.svm.core.util.VMError$HostedError: java.lang.reflect.InvocationTargetException
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisError.shouldNotReachHere(AnalysisError.java:173)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisFuture.ensureDone(AnalysisFuture.java:66)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.lambda$postTask$12(ImageHeapScanner.java:663)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:193)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:177)
    at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1395)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.util.concurrent.ExecutionException: com.oracle.svm.core.util.VMError$HostedError: java.lang.reflect.InvocationTargetException
    at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisFuture.ensureDone(AnalysisFuture.java:64)
    ... 9 more
Caused by: com.oracle.svm.core.util.VMError$HostedError: java.lang.reflect.InvocationTargetException
    at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:72)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.annotation.AnnotationSubstitutionField.readValue(AnnotationSubstitutionField.java:131)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.readHostedFieldValue(AnalysisConstantReflectionProvider.java:123)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.heap.SVMImageHeapScanner.readHostedFieldValue(SVMImageHeapScanner.java:122)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.createImageHeapObject(ImageHeapScanner.java:277)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.lambda$getOrCreateConstantReachableTask$2(ImageHeapScanner.java:203)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisFuture.ensureDone(AnalysisFuture.java:63)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.getOrCreateConstantReachableTask(ImageHeapScanner.java:215)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.heap.SVMImageHeapScanner.getOrCreateConstantReachableTask(SVMImageHeapScanner.java:95)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.markConstantReachable(ImageHeapScanner.java:179)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.onFieldValueReachable(ImageHeapScanner.java:357)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.lambda$createImageHeapObject$3(ImageHeapScanner.java:284)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisFuture.ensureDone(AnalysisFuture.java:63)
    ... 9 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.annotation.AnnotationSubstitutionField.readValue(AnnotationSubstitutionField.java:114)
    ... 22 more
Caused by: java.lang.annotation.AnnotationTypeMismatchException: Incorrectly typed data found for annotation element public abstract org.eclipse.microprofile.openapi.annotations.enums.SchemaType org.eclipse.microprofile.openapi.annotations.media.Schema.type() (Found data of type java.lang.String[ARRAY])
    at java.base/sun.reflect.annotation.AnnotationTypeMismatchExceptionProxy.generateException(AnnotationTypeMismatchExceptionProxy.java:59)
    at java.base/sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:89)
    at org.graalvm.nativeimage.builder/com.oracle.svm.core.SubstrateAnnotationInvocationHandler.invoke(SubstrateAnnotationInvocationHandler.java:52)
    at jdk.proxy4/jdk.proxy4.$Proxy141.type(Unknown Source)
    ... 27 more

How to Reproduce?

  1. git clone git@github.com:fedinskiy/quarkus-test-suite.git -b reproducer/openapi-failure
  2. cd quarkus-test-suite/spring/spring-data
  3. mvn clean verify -Dnative -Dquarkus.platform.version=2.16.1.Final -Pfail
  4. mvn clean verify -Dnative -Dquarkus.platform.version=2.16.1.Final — this compiles, but expectedly fails during test phase due to lack of q/openapi endpoint

Output of uname -a or ver

6.0.18-300.fc37.x86_64

Output of java -version

17.0.6, vendor: GraalVM Community

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.16.1.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)

Additional information

No response

quarkus-bot[bot] commented 1 year ago

/cc @EricWittmann (openapi), @Ladicek (smallrye), @MikeEdgar (openapi), @jmartisk (smallrye), @phillip-kruger (openapi,smallrye), @radcortez (smallrye)

geoand commented 1 year ago

@zakkak @galderz any idea what this error actually means?

zakkak commented 1 year ago

@fedinskiy I tried reproducing the issue with no luck.

Note that mvn clean verify -Dnative -Dquarkus.platform.version=2.16.1.Final -Pfail fails before the native image generation with:

2023-02-06 13:44:00,186 INFO  [🐳 .3.4]] (build-42) Container testcontainers/ryuk:0.3.4 is starting: e1e6479a765b408826058df5e9be5ed9a20ca9723ab382e6488099fe1e1d54c7
2023-02-06 13:44:00,969 ERROR [🐳 .3.4]] (build-42) Could not start container: com.github.dockerjava.api.exception.NotFoundException: Status 404: {"message":"No such container: e1e6479a765b408826058df5e9be5ed9a20ca9723ab382e6488099fe1e1d54c7"}

    at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:241)
    at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.get(DefaultInvocationBuilder.java:202)
    at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.get(DefaultInvocationBuilder.java:74)
    at org.testcontainers.shaded.com.github.dockerjava.core.exec.InspectContainerCmdExec.execute(InspectContainerCmdExec.java:31)
    at org.testcontainers.shaded.com.github.dockerjava.core.exec.InspectContainerCmdExec.execute(InspectContainerCmdExec.java:13)
    at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:21)
    at org.testcontainers.shaded.com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:35)
    at org.testcontainers.shaded.com.github.dockerjava.core.command.InspectContainerCmdImpl.exec(InspectContainerCmdImpl.java:52)
    at org.testcontainers.containers.GenericContainer.lambda$tryStart$1(GenericContainer.java:456)
    at org.testcontainers.shaded.org.awaitility.core.AbstractHamcrestCondition.lambda$new$0(AbstractHamcrestCondition.java:48)
    at org.testcontainers.shaded.org.awaitility.core.ConditionAwaiter$ConditionPoller.call(ConditionAwaiter.java:248)
    at org.testcontainers.shaded.org.awaitility.core.ConditionAwaiter$ConditionPoller.call(ConditionAwaiter.java:235)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.testcontainers.shaded.org.awaitility.core.SameThreadExecutorService.execute(SameThreadExecutorService.java:79)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
    at org.testcontainers.shaded.org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:101)
    at org.testcontainers.shaded.org.awaitility.core.AbstractHamcrestCondition.await(AbstractHamcrestCondition.java:86)
    at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:985)
    at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:691)
    at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:708)
    at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:455)
    at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:344)
    at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
    at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:334)
    at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
    at org.testcontainers.utility.RyukResourceReaper.maybeStart(RyukResourceReaper.java:78)
    at org.testcontainers.utility.RyukResourceReaper.register(RyukResourceReaper.java:68)
    at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:423)
    at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:344)
    at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
    at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:334)
    at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
    at io.quarkus.devservices.postgresql.deployment.PostgresqlDevServicesProcessor$1.startDatabase(PostgresqlDevServicesProcessor.java:64)
    at io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor.startDevDb(DevServicesDatasourceProcessor.java:281)
    at io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor.launchDatabases(DevServicesDatasourceProcessor.java:136)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:281)
    at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
    at java.base/java.lang.Thread.run(Thread.java:833)
    at org.jboss.threads.JBossThread.run(JBossThread.java:501)

2023-02-06 13:44:00,975 ERROR [🐳 .3.4]] (build-42) There are no stdout/stderr logs available for the failed container
2023-02-06 13:44:00,975 ERROR [🐳 .io/postgres:14]] (build-42) Could not start container: org.testcontainers.containers.ContainerLaunchException: Container startup failed
    at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:349)
    at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
    at org.testcontainers.utility.RyukResourceReaper.maybeStart(RyukResourceReaper.java:78)
    at org.testcontainers.utility.RyukResourceReaper.register(RyukResourceReaper.java:68)
    at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:423)
    at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:344)
    at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
    at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:334)
    at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
    at io.quarkus.devservices.postgresql.deployment.PostgresqlDevServicesProcessor$1.startDatabase(PostgresqlDevServicesProcessor.java:64)
    at io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor.startDevDb(DevServicesDatasourceProcessor.java:281)
    at io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor.launchDatabases(DevServicesDatasourceProcessor.java:136)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:281)
    at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
    at java.base/java.lang.Thread.run(Thread.java:833)
    at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
    at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88)
    at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:334)
    ... 22 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
    at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:542)
    at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:344)
    at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
    ... 23 more
Caused by: com.github.dockerjava.api.exception.NotFoundException: Status 404: {"message":"No such container: e1e6479a765b408826058df5e9be5ed9a20ca9723ab382e6488099fe1e1d54c7"}

    at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:241)
    at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.get(DefaultInvocationBuilder.java:202)
    at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.get(DefaultInvocationBuilder.java:74)
    at org.testcontainers.shaded.com.github.dockerjava.core.exec.InspectContainerCmdExec.execute(InspectContainerCmdExec.java:31)
    at org.testcontainers.shaded.com.github.dockerjava.core.exec.InspectContainerCmdExec.execute(InspectContainerCmdExec.java:13)
    at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:21)
    at org.testcontainers.shaded.com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:35)
    at org.testcontainers.shaded.com.github.dockerjava.core.command.InspectContainerCmdImpl.exec(InspectContainerCmdImpl.java:52)
    at org.testcontainers.containers.GenericContainer.lambda$tryStart$1(GenericContainer.java:456)
    at org.testcontainers.shaded.org.awaitility.core.AbstractHamcrestCondition.lambda$new$0(AbstractHamcrestCondition.java:48)
    at org.testcontainers.shaded.org.awaitility.core.ConditionAwaiter$ConditionPoller.call(ConditionAwaiter.java:248)
    at org.testcontainers.shaded.org.awaitility.core.ConditionAwaiter$ConditionPoller.call(ConditionAwaiter.java:235)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.testcontainers.shaded.org.awaitility.core.SameThreadExecutorService.execute(SameThreadExecutorService.java:79)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
    at org.testcontainers.shaded.org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:101)
    at org.testcontainers.shaded.org.awaitility.core.AbstractHamcrestCondition.await(AbstractHamcrestCondition.java:86)
    at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:985)
    at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:691)
    at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:708)
    at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:455)
    ... 25 more

[ERROR] Tests run: 31, Failures: 0, Errors: 1, Skipped: 30, Time elapsed: 2.925 s <<< FAILURE! - in io.quarkus.ts.spring.data.di.SpringDiTest
[ERROR] beanExists{Class}[1]  Time elapsed: 0.004 s  <<< ERROR!

So I used mvn clean verify -DskipTests -Dnative -Dquarkus.platform.version=2.16.1.Final -Pfail instead which successfully built the native image.

Could you please include the logs before the "Performing analysis" part as well?

e.g.:

[INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building native image source jar: /home/zakkak/code/tmp/quarkus-test-suite/spring/spring-data/target/spring-data-1.0.0-SNAPSHOT-native-image-source-jar/spring-data-1.0.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Building native image from /home/zakkak/code/tmp/quarkus-test-suite/spring/spring-data/target/spring-data-1.0.0-SNAPSHOT-native-image-source-jar/spring-data-1.0.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildContainerRunner] Using docker to run the native image builder
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildContainerRunner] Checking image status quay.io/quarkus/ubi-quarkus-mandrel-builder-image:22.3-java17
22.3-java17: Pulling from quarkus/ubi-quarkus-mandrel-builder-image
Digest: sha256:e7734de2f82fc5c8fc8f26ef5b4e311f8f6e7a922ad614c0c6aaa5a4baa63d77
Status: Image is up to date for quay.io/quarkus/ubi-quarkus-mandrel-builder-image:22.3-java17
quay.io/quarkus/ubi-quarkus-mandrel-builder-image:22.3-java17
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on native-image 22.3.1.0-Final Mandrel Distribution (Java Version 17.0.6+10)
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] docker run --env LANG=C --rm --user 1000:1000 -v /home/zakkak/code/tmp/quarkus-test-suite/spring/spring-data/target/spring-data-1.0.0-SNAPSHOT-native-image-source-jar:/project:z --name build-native-WPuTQ quay.io/quarkus/ubi-quarkus-mandrel-builder-image:22.3-java17 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-DCoordinatorEnvironmentBean.transactionStatusManagerEnable=false -J-Dlogging.initial-configurator.min-level=500 -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=3 -J-Duser.language=en -J-Duser.country=IE -J-Dfile.encoding=UTF-8 --features=org.hibernate.graalvm.internal.QueryParsingSupport,io.quarkus.runner.Feature,io.quarkus.runtime.graal.ResourcesFeature,org.hibernate.graalvm.internal.GraalVMStaticFeature,io.quarkus.caffeine.runtime.graal.CacheConstructorsFeature,io.quarkus.runtime.graal.DisableLoggingFeature,io.quarkus.hibernate.validator.runtime.DisableLoggingFeature,io.quarkus.jdbc.postgresql.runtime.graal.SQLXMLFeature,io.quarkus.hibernate.orm.runtime.graal.DisableLoggingFeature -J--add-exports=java.security.jgss/sun.security.krb5=ALL-UNNAMED -J--add-opens=java.base/java.text=ALL-UNNAMED -J--add-opens=java.base/java.io=ALL-UNNAMED -J--add-opens=java.base/java.lang.invoke=ALL-UNNAMED -J--add-opens=java.base/java.util=ALL-UNNAMED -H:+CollectImageBuildStatistics -H:ImageBuildStatisticsFile=spring-data-1.0.0-SNAPSHOT-runner-timing-stats.json -H:BuildOutputJSONFile=spring-data-1.0.0-SNAPSHOT-runner-build-output-stats.json -H:+AllowFoldMethods -J-Djava.awt.headless=true --no-fallback --link-at-build-time -H:+ReportExceptionStackTraces -J-Xmx4g -H:-AddAllCharsets --enable-url-protocols=http,https -H:-UseServiceLoaderFeature -H:+StackTrace -J--add-exports=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED -J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED --exclude-config io\.netty\.netty-codec /META-INF/native-image/io\.netty/netty-codec/generated/handlers/reflect-config\.json --exclude-config io\.netty\.netty-handler /META-INF/native-image/io\.netty/netty-handler/generated/handlers/reflect-config\.json spring-data-1.0.0-SNAPSHOT-runner -jar spring-data-1.0.0-SNAPSHOT-runner.jar
========================================================================================================================
GraalVM Native Image: Generating 'spring-data-1.0.0-SNAPSHOT-runner' (executable)...
========================================================================================================================
[1/7] Initializing...                                                                                    (5.3s @ 0.40GB)
 Version info: 'GraalVM 22.3.1.0-Final Java 17 Mandrel Distribution'
 Java version info: '17.0.6+10'
 C compiler: gcc (redhat, x86_64, 8.5.0)
 Garbage collector: Serial GC
 9 user-specific feature(s)
 - io.quarkus.caffeine.runtime.graal.CacheConstructorsFeature
 - io.quarkus.hibernate.orm.runtime.graal.DisableLoggingFeature: Disables INFO logging during the analysis phase for the [org.hibernate.Version, org.hibernate.annotations.common.Version, org.hibernate.dialect.Dialect] categories
 - io.quarkus.hibernate.validator.runtime.DisableLoggingFeature: Disables INFO logging during the analysis phase for the [org.hibernate.validator.internal.util.Version] categories
 - io.quarkus.jdbc.postgresql.runtime.graal.SQLXMLFeature
 - io.quarkus.runner.Feature: Auto-generated class by Quarkus from the existing extensions
 - io.quarkus.runtime.graal.DisableLoggingFeature: Disables INFO logging during the analysis phase for the [org.jboss.threads] categories
 - io.quarkus.runtime.graal.ResourcesFeature: Register each line in META-INF/quarkus-native-resources.txt as a resource on Substrate VM
 - org.hibernate.graalvm.internal.GraalVMStaticFeature: Hibernate ORM's static reflection registrations for GraalVM
 - org.hibernate.graalvm.internal.QueryParsingSupport: Hibernate ORM's support for HQL Parser in GraalVM

Thanks

fedinskiy commented 1 year ago

mvn clean verify -DskipTests -Dnative -Dquarkus.platform.version=2.16.1.Final -Pfail fails for me as well

FO] --- quarkus-maven-plugin:2.16.1.Final:build (build) @ spring-data ---
[INFO] [io.quarkus.elytron.security.properties.deployment.ElytronPropertiesProcessor] Configuring from MPRealmConfig
[INFO] [org.hibernate.Version] HHH000412: Hibernate ORM core version 5.6.14.Final
[INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building native image source jar: /home/fedinskiy/code/quarkus/tests/spring/spring-data/target/spring-data-1.0.0-SNAPSHOT-native-image-source-jar/spring-data-1.0.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Building native image from /home/fedinskiy/code/quarkus/tests/spring/spring-data/target/spring-data-1.0.0-SNAPSHOT-native-image-source-jar/spring-data-1.0.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildContainerRunner] Using docker to run the native image builder
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildContainerRunner] Checking image status quay.io/quarkus/ubi-quarkus-mandrel-builder-image:22.3-java17
22.3-java17: Pulling from quarkus/ubi-quarkus-mandrel-builder-image
Digest: sha256:e7734de2f82fc5c8fc8f26ef5b4e311f8f6e7a922ad614c0c6aaa5a4baa63d77
Status: Image is up to date for quay.io/quarkus/ubi-quarkus-mandrel-builder-image:22.3-java17
quay.io/quarkus/ubi-quarkus-mandrel-builder-image:22.3-java17
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on native-image 22.3.1.0-Final Mandrel Distribution (Java Version 17.0.6+10)
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] docker run --env LANG=C --rm --user 1000:1000 -v /home/fedinskiy/code/quarkus/tests/spring/spring-data/target/spring-data-1.0.0-SNAPSHOT-native-image-source-jar:/project:z --name build-native-pNVDt quay.io/quarkus/ubi-quarkus-mandrel-builder-image:22.3-java17 -J-Dlogging.initial-configurator.min-level=500 -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-DCoordinatorEnvironmentBean.transactionStatusManagerEnable=false -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=3 -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Duser.language=en -J-Duser.country=GB -J-Dfile.encoding=UTF-8 --features=io.quarkus.hibernate.validator.runtime.DisableLoggingFeature,io.quarkus.caffeine.runtime.graal.CacheConstructorsFeature,org.hibernate.graalvm.internal.QueryParsingSupport,io.quarkus.runner.Feature,io.quarkus.runtime.graal.ResourcesFeature,io.quarkus.runtime.graal.DisableLoggingFeature,io.quarkus.hibernate.orm.runtime.graal.DisableLoggingFeature,io.quarkus.jdbc.postgresql.runtime.graal.SQLXMLFeature,org.hibernate.graalvm.internal.GraalVMStaticFeature -J--add-exports=java.security.jgss/sun.security.krb5=ALL-UNNAMED -J--add-opens=java.base/java.text=ALL-UNNAMED -J--add-opens=java.base/java.io=ALL-UNNAMED -J--add-opens=java.base/java.lang.invoke=ALL-UNNAMED -J--add-opens=java.base/java.util=ALL-UNNAMED -H:+CollectImageBuildStatistics -H:ImageBuildStatisticsFile=spring-data-1.0.0-SNAPSHOT-runner-timing-stats.json -H:BuildOutputJSONFile=spring-data-1.0.0-SNAPSHOT-runner-build-output-stats.json -H:+AllowFoldMethods -J-Djava.awt.headless=true --no-fallback --link-at-build-time -H:+ReportExceptionStackTraces -J-Xmx4g -H:-AddAllCharsets --enable-url-protocols=http,https -H:-UseServiceLoaderFeature -H:+StackTrace -J--add-exports=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED -J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED --exclude-config io\.netty\.netty-codec /META-INF/native-image/io\.netty/netty-codec/generated/handlers/reflect-config\.json --exclude-config io\.netty\.netty-handler /META-INF/native-image/io\.netty/netty-handler/generated/handlers/reflect-config\.json spring-data-1.0.0-SNAPSHOT-runner -jar spring-data-1.0.0-SNAPSHOT-runner.jar
========================================================================================================================
GraalVM Native Image: Generating 'spring-data-1.0.0-SNAPSHOT-runner' (executable)...
========================================================================================================================
[1/7] Initializing...                                                                                   (12.3s @ 0.41GB)
 Version info: 'GraalVM 22.3.1.0-Final Java 17 Mandrel Distribution'
 Java version info: '17.0.6+10'
 C compiler: gcc (redhat, x86_64, 8.5.0)
 Garbage collector: Serial GC
 9 user-specific feature(s)
 - io.quarkus.caffeine.runtime.graal.CacheConstructorsFeature
 - io.quarkus.hibernate.orm.runtime.graal.DisableLoggingFeature: Disables INFO logging during the analysis phase for the [org.hibernate.Version, org.hibernate.annotations.common.Version, org.hibernate.dialect.Dialect] categories
 - io.quarkus.hibernate.validator.runtime.DisableLoggingFeature: Disables INFO logging during the analysis phase for the [org.hibernate.validator.internal.util.Version] categories
 - io.quarkus.jdbc.postgresql.runtime.graal.SQLXMLFeature
 - io.quarkus.runner.Feature: Auto-generated class by Quarkus from the existing extensions
 - io.quarkus.runtime.graal.DisableLoggingFeature: Disables INFO logging during the analysis phase for the [org.jboss.threads] categories
 - io.quarkus.runtime.graal.ResourcesFeature: Register each line in META-INF/quarkus-native-resources.txt as a resource on Substrate VM
 - org.hibernate.graalvm.internal.GraalVMStaticFeature: Hibernate ORM's static reflection registrations for GraalVM
 - org.hibernate.graalvm.internal.QueryParsingSupport: Hibernate ORM's support for HQL Parser in GraalVM

Also it looks like I mistyped version of GraalVM, and it is actually 17.0.6

zakkak commented 1 year ago

I finally managed to reproduce this using mvnw.

mvn clean verify -DskipTests -Dnative -Dquarkus.platform.version=2.16.1.Final -Pfail works

../../mvnw clean verify -DskipTests -Dnative -Dquarkus.platform.version=2.16.1.Final -Pfail fails

Still not clear to me why though...

Also FTR, I was able to run without -DskipTests using export TESTCONTAINERS_RYUK_DISABLED=true as suggested in https://bugzilla.redhat.com/show_bug.cgi?id=1758227#c4

zakkak commented 1 year ago

If I get this right, the issue is caused by https://github.com/quarkusio/quarkus/pull/28811/files#diff-da0096dd9784cf26970e40b6ca83158411a9c990e3e687184dd00c3590bf10b0R189

Which instead of defining the type as type = SchemaType.ARRAY it defines it as type = "ARRAY", e.g:

    @GET
    @Path("")
    @Produces({"application/json"})
    @LinkResource(
        entityClassName = "io.quarkus.ts.spring.data.primitivetypes.model.Cat",
        rel = "list"
    )
    @APIResponse(
        responseCode = "200",
        content = {@Content(
    mediaType = "application/json",
    schema = @Schema(
    implementation = Cat.class,
    type = "ARRAY"                                 //  <============================
)
)}
    )
    public Response list(@QueryParam("sort") List sort, @QueryParam("namedQuery") String namedQuery) {

which should be:

    @GET
    @Path("")
    @Produces({"application/json"})
    @LinkResource(
        entityClassName = "io.quarkus.ts.spring.data.primitivetypes.model.Cat",
        rel = "list"
    )
    @APIResponse(
        responseCode = "200",
        content = {@Content(
    mediaType = "application/json",
    schema = @Schema(
    implementation = Cat.class,
    type = SchemaType.ARRAY                        // <======================================
)
)}
    )
    public Response list(@QueryParam("sort") List sort, @QueryParam("namedQuery") String namedQuery) {

This results in Quarkus generating methods wrongfully annotated that then fail native image compilation with the above error. Not sure why this is not happening in JVM-mode though, it doesn't seem like a native issue.

ping @Sgitario

Sgitario commented 1 year ago

This resource is autogenerated and as far as I remember, we could not use SchemaType.ARRAY directly, though I can try again.

However, why this is working fine in JVM and not in Native?

geoand commented 1 year ago

Is there some kind of constant folding going on?

On Mon, Feb 6, 2023, 17:58 Jose Carvajal @.***> wrote:

This resource is autogenerated and as far as I remember, we could not use SchemaType.ARRAY directly, though I can try again.

However, why this is working fine in JVM and not in Native?

— Reply to this email directly, view it on GitHub https://github.com/quarkusio/quarkus/issues/30919#issuecomment-1419318771, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBMDP5SIIVDFKO3O6P2MW3WWENTTANCNFSM6AAAAAAUSQLMSQ . You are receiving this because you commented.Message ID: @.***>

zakkak commented 1 year ago

My understanding is that this doesn't have to do with constant folding or similar optimizations, native-image seems to trigger a check (when parsing the bytecode) that the JVM for some reason doesn't. I can have a deeper look if necessary (just let me know), but the use of a String there seems wrong to me, no matter if it's being caught or not in JVM-mode.

Sgitario commented 1 year ago

https://github.com/quarkusio/quarkus/pull/30940 should address this issue. I verified that now the native compilation works using the reproducer (I had to migrate the javax packages to jakarta but that's expected for 999-SNAPSHOT).