Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vert.x QuarkusJacksonJsonCodec cannot serialize JSON from records in Native due to Jackson error #20490

Closed
murphye opened this issue Oct 1, 2021 · 10 comments
Labels
area/jackson Issues related to Jackson (JSON library) kind/bug Something isn't working triage/duplicate This issue or pull request already exists

Comments

@murphye
Copy link

murphye commented Oct 1, 2021

Describe the bug

When using Vert.x Web in native mode, QuarkusJacksonJsonCodec fails to serialize record objects to JSON. This seems to work OK when running in regular JRE.

The error itself stems from Jackson JDK14Util. Here is where the error stems from in Jackson https://github.com/FasterXML/jackson-databind/blob/2.13/src/main/java/com/fasterxml/jackson/databind/jdk14/JDK14Util.java#L123

Expected behavior

record objects are serialized to JSON when using Quarkus native.

Actual behavior

Stack trace

2021-10-01 04:13:20,921 ERROR [io.ver.ext.web.RoutingContext] (vert.x-eventloop-thread-1) Unhandled exception in router: io.vertx.core.json.EncodeException: Failed to encode as JSON: Failed to access RecordComponents of type `org.acme.Pet` (through reference chain: java.util.ArrayList[0])
        at io.quarkus.vertx.runtime.jackson.QuarkusJacksonJsonCodec.toString(QuarkusJacksonJsonCodec.java:147)
        at io.vertx.core.json.JsonArray.encode(JsonArray.java:536)
        at org.acme.PetStoreRouter.listPets(PetStoreRouter.java:51)
        at io.vertx.mutiny.ext.web.openapi.Operation$1.handle(Operation.java:78)
        at io.vertx.mutiny.ext.web.openapi.Operation$1.handle(Operation.java:76)
        at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1127)
        at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:114)
        at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
        at io.vertx.ext.web.validation.impl.ValidationHandlerImpl.lambda$handle$5(ValidationHandlerImpl.java:168)
        at io.vertx.core.impl.future.SucceededFuture.onComplete(SucceededFuture.java:81)
        at io.vertx.ext.web.validation.impl.ValidationHandlerImpl.handle(ValidationHandlerImpl.java:159)
        at io.vertx.ext.web.validation.impl.ValidationHandlerImpl.handle(ValidationHandlerImpl.java:18)
        at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1127)
        at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:114)
        at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
        at io.vertx.ext.web.handler.impl.ResponseContentTypeHandlerImpl.handle(ResponseContentTypeHandlerImpl.java:54)
        at io.vertx.ext.web.handler.impl.ResponseContentTypeHandlerImpl.handle(ResponseContentTypeHandlerImpl.java:28)
        at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1127)
        at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:151)
        at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
        at io.vertx.ext.web.handler.impl.BodyHandlerImpl.handle(BodyHandlerImpl.java:94)
        at io.vertx.ext.web.handler.impl.BodyHandlerImpl.handle(BodyHandlerImpl.java:44)
        at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1127)
        at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:151)
        at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
        at io.vertx.ext.web.impl.RouterImpl.handleContext(RouterImpl.java:236)
        at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1127)
        at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:151)
        at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:133)
        at io.vertx.ext.web.handler.impl.BodyHandlerImpl$BHandler.doEnd(BodyHandlerImpl.java:313)
        at io.vertx.ext.web.handler.impl.BodyHandlerImpl$BHandler.end(BodyHandlerImpl.java:290)
        at io.vertx.ext.web.handler.impl.BodyHandlerImpl.lambda$handle$0(BodyHandlerImpl.java:86)
        at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:100)
        at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:63)
        at io.vertx.core.http.impl.HttpEventHandler.handleEnd(HttpEventHandler.java:76)
        at io.vertx.core.http.impl.Http1xServerRequest.onEnd(Http1xServerRequest.java:565)
        at io.vertx.core.http.impl.Http1xServerRequest.lambda$pendingQueue$1(Http1xServerRequest.java:127)
        at io.vertx.core.streams.impl.InboundBuffer.handleEvent(InboundBuffer.java:240)
        at io.vertx.core.streams.impl.InboundBuffer.write(InboundBuffer.java:130)
        at io.vertx.core.http.impl.Http1xServerRequest.handleEnd(Http1xServerRequest.java:546)
        at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:71)
        at io.vertx.core.impl.DuplicatedContext.execute(DuplicatedContext.java:163)
        at io.vertx.core.http.impl.Http1xServerConnection.onEnd(Http1xServerConnection.java:189)
        at io.vertx.core.http.impl.Http1xServerConnection.handleMessage(Http1xServerConnection.java:145)
        at io.vertx.core.net.impl.ConnectionBase.read(ConnectionBase.java:155)
        at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:154)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
        at io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandler.channelRead(WebSocketServerExtensionHandler.java:99)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at io.vertx.core.http.impl.Http1xOrH2CHandler.end(Http1xOrH2CHandler.java:61)
        at io.vertx.core.http.impl.Http1xOrH2CHandler.channelRead(Http1xOrH2CHandler.java:38)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:831)
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:567)
        at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)

How to Reproduce?

Check out this branch: https://github.com/murphye/vertx-web-openapi-quarkus-petstore/tree/QuarkusJacksonJsonCodec-RecordComponents-Native

./mvnw clean package -Pnative -Dquarkus.native.container-build=true -Dquarkus.container-image.build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-native-image:21.2.0-java16
docker run -p 8080:8080 eric/petstore:1.0.0-SNAPSHOT
curl localhost:8080/pets

Check the logs and you will see the stack trace.

Output of uname -a or ver

Darwin erics-mbp-2.lan 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64

Output of java -version

No response

GraalVM version (if different from Java)

Using quay.io/quarkus/ubi-quarkus-native-image:21.2.0-java16

Quarkus version or git rev

No response

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

No response

Additional information

No response

@murphye murphye added the kind/bug Something isn't working label Oct 1, 2021
@quarkus-bot quarkus-bot bot added the area/jackson Issues related to Jackson (JSON library) label Oct 1, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Oct 1, 2021

/cc @geoand, @gsmet

@murphye murphye changed the title QuarkusJacksonJsonCodec Failed to access RecordComponents in Native Mode Vert.x QuarkusJacksonJsonCodec Failed to access RecordComponents in Native Mode Oct 1, 2021
@murphye
Copy link
Author

murphye commented Oct 1, 2021

@murphye
Copy link
Author

murphye commented Oct 1, 2021

Note: I removed the use of Optional in Pet.java and that did not have an effect. Was worth a try.

@murphye murphye changed the title Vert.x QuarkusJacksonJsonCodec Failed to access RecordComponents in Native Mode Vert.x QuarkusJacksonJsonCodec cannot serialize JSON from records in Native due to Jackson error Oct 1, 2021
@geoand
Copy link
Contributor

geoand commented Oct 1, 2021

Thanks for reporting.

If you annotate Pet with @RegisterForReflection it should work in native as well.

Can you give it a shot?

@murphye
Copy link
Author

murphye commented Oct 1, 2021

@geoand Unfortunately after adding @RegisterForReflection I get a native build error.

Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported method java.lang.Class.getConstantPool() is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Detailed message:
Trace: 
        at parsing java.lang.System$2.getConstantPool(System.java:2148)
Call path from entry point to java.lang.System$2.getConstantPool(Class): 
        at java.lang.System$2.getConstantPool(System.java:2148)
        at java.lang.reflect.RecordComponent.declaredAnnotations(RecordComponent.java:198)
        at java.lang.reflect.RecordComponent.getAnnotation(RecordComponent.java:181)
        at io.smallrye.config.ConfigMappingInterface.getPropertyName(ConfigMappingInterface.java:691)
        at io.smallrye.config.ConfigMappingInterface.getPropertyDef(ConfigMappingInterface.java:622)
        at io.smallrye.config.ConfigMappingInterface.getProperties(ConfigMappingInterface.java:607)
        at io.smallrye.config.ConfigMappingInterface.createConfigurationInterface(ConfigMappingInterface.java:564)
        at io.smallrye.config.ConfigMappingInterface.access$000(ConfigMappingInterface.java:27)
        at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:32)
        at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:30)
        at com.oracle.svm.core.jdk.Target_java_lang_ClassValue.get(JavaLangSubstitutions.java:599)
        at io.quarkus.runtime.configuration.Substitutions$Target_ConfigMappingInterface.getConfigurationInterface(Substitutions.java:86)
        at io.smallrye.config.ConfigMappingContext.lambda$getKeyConverter$6(ConfigMappingContext.java:142)
        at io.smallrye.config.ConfigMappingContext$$Lambda$1240/0x00000007c15b6240.apply(Unknown Source)
        at sun.security.ec.ParametersMap$1.get(ParametersMap.java:78)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.initializeLazyValue(SystemPropertiesSupport.java:216)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.getProperty(SystemPropertiesSupport.java:169)
        at com.oracle.svm.core.jdk.Target_java_lang_System.getProperty(JavaLangSubstitutions.java:290)
        at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VARARGS:Ljava_lang_System_2_0002egetProperty_00028Ljava_lang_String_2_00029Ljava_lang_String_2(generated:0)

com.oracle.svm.core.util.UserError$UserException: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported method java.lang.Class.getConstantPool() is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Detailed message:
Trace: 
        at parsing java.lang.System$2.getConstantPool(System.java:2148)
Call path from entry point to java.lang.System$2.getConstantPool(Class): 
        at java.lang.System$2.getConstantPool(System.java:2148)
        at java.lang.reflect.RecordComponent.declaredAnnotations(RecordComponent.java:198)
        at java.lang.reflect.RecordComponent.getAnnotation(RecordComponent.java:181)
        at io.smallrye.config.ConfigMappingInterface.getPropertyName(ConfigMappingInterface.java:691)
        at io.smallrye.config.ConfigMappingInterface.getPropertyDef(ConfigMappingInterface.java:622)
        at io.smallrye.config.ConfigMappingInterface.getProperties(ConfigMappingInterface.java:607)
        at io.smallrye.config.ConfigMappingInterface.createConfigurationInterface(ConfigMappingInterface.java:564)
        at io.smallrye.config.ConfigMappingInterface.access$000(ConfigMappingInterface.java:27)
        at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:32)
        at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:30)
        at com.oracle.svm.core.jdk.Target_java_lang_ClassValue.get(JavaLangSubstitutions.java:599)
        at io.quarkus.runtime.configuration.Substitutions$Target_ConfigMappingInterface.getConfigurationInterface(Substitutions.java:86)
        at io.smallrye.config.ConfigMappingContext.lambda$getKeyConverter$6(ConfigMappingContext.java:142)
        at io.smallrye.config.ConfigMappingContext$$Lambda$1240/0x00000007c15b6240.apply(Unknown Source)
        at sun.security.ec.ParametersMap$1.get(ParametersMap.java:78)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.initializeLazyValue(SystemPropertiesSupport.java:216)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.getProperty(SystemPropertiesSupport.java:169)
        at com.oracle.svm.core.jdk.Target_java_lang_System.getProperty(JavaLangSubstitutions.java:290)
        at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VARARGS:Ljava_lang_System_2_0002egetProperty_00028Ljava_lang_String_2_00029Ljava_lang_String_2(generated:0)

        at com.oracle.svm.core.util.UserError.abort(UserError.java:82)
        at com.oracle.svm.hosted.FallbackFeature.reportAsFallback(FallbackFeature.java:233)
        at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:764)
        at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:532)
        at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:491)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:380)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:543)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:119)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:573)
Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported method java.lang.Class.getConstantPool() is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Detailed message:
Trace: 
        at parsing java.lang.System$2.getConstantPool(System.java:2148)
Call path from entry point to java.lang.System$2.getConstantPool(Class): 
        at java.lang.System$2.getConstantPool(System.java:2148)
        at java.lang.reflect.RecordComponent.declaredAnnotations(RecordComponent.java:198)
        at java.lang.reflect.RecordComponent.getAnnotation(RecordComponent.java:181)
        at io.smallrye.config.ConfigMappingInterface.getPropertyName(ConfigMappingInterface.java:691)
        at io.smallrye.config.ConfigMappingInterface.getPropertyDef(ConfigMappingInterface.java:622)
        at io.smallrye.config.ConfigMappingInterface.getProperties(ConfigMappingInterface.java:607)
        at io.smallrye.config.ConfigMappingInterface.createConfigurationInterface(ConfigMappingInterface.java:564)
        at io.smallrye.config.ConfigMappingInterface.access$000(ConfigMappingInterface.java:27)
        at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:32)
        at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:30)
        at com.oracle.svm.core.jdk.Target_java_lang_ClassValue.get(JavaLangSubstitutions.java:599)
        at io.quarkus.runtime.configuration.Substitutions$Target_ConfigMappingInterface.getConfigurationInterface(Substitutions.java:86)
        at io.smallrye.config.ConfigMappingContext.lambda$getKeyConverter$6(ConfigMappingContext.java:142)
        at io.smallrye.config.ConfigMappingContext$$Lambda$1240/0x00000007c15b6240.apply(Unknown Source)
        at sun.security.ec.ParametersMap$1.get(ParametersMap.java:78)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.initializeLazyValue(SystemPropertiesSupport.java:216)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.getProperty(SystemPropertiesSupport.java:169)
        at com.oracle.svm.core.jdk.Target_java_lang_System.getProperty(JavaLangSubstitutions.java:290)
        at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VARARGS:Ljava_lang_System_2_0002egetProperty_00028Ljava_lang_String_2_00029Ljava_lang_String_2(generated:0)

        at com.oracle.graal.pointsto.constraints.UnsupportedFeatures.report(UnsupportedFeatures.java:126)
        at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:761)
        ... 6 more
Caused by: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported method java.lang.Class.getConstantPool() is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
        at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.lookup(AnnotationSubstitutionProcessor.java:188)
        at com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor$ChainedSubstitutionProcessor.lookup(SubstitutionProcessor.java:140)
        at com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor$ChainedSubstitutionProcessor.lookup(SubstitutionProcessor.java:140)
        at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:416)
        at com.oracle.graal.pointsto.infrastructure.WrappedConstantPool.lookupMethod(WrappedConstantPool.java:125)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.lookupMethodInPool(BytecodeParser.java:4304)
        at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.lookupMethodInPool(SharedGraphBuilderPhase.java:144)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.lookupMethod(BytecodeParser.java:4298)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genInvokeVirtual(BytecodeParser.java:1695)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5371)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3431)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.handleBytecodeBlock(BytecodeParser.java:3391)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3236)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1122)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1007)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:84)
        at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:81)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:212)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
        at com.oracle.graal.pointsto.flow.AnalysisParsedGraph.parseBytecode(AnalysisParsedGraph.java:131)
        at com.oracle.svm.hosted.SVMHost.parseBytecode(SVMHost.java:709)
        at com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:605)
        at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:163)
        at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:321)
        at com.oracle.graal.pointsto.flow.MethodTypeFlow.createTypeFlow(MethodTypeFlow.java:293)
        at com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureTypeFlowCreated(MethodTypeFlow.java:282)
        at com.oracle.graal.pointsto.flow.MethodTypeFlow.addContext(MethodTypeFlow.java:103)
        at com.oracle.graal.pointsto.DefaultAnalysisPolicy$DefaultVirtualInvokeTypeFlow.onObservedUpdate(DefaultAnalysisPolicy.java:222)
        at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:471)
        at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:540)
        at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:539)
        at com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:188)
        at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:172)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1434)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:295)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
[petstore-1.0.0-SNAPSHOT-runner:27]      [total]:  46,010.73 ms,  2.56 GB
# Printing build artifacts to: /project/petstore-1.0.0-SNAPSHOT-runner.build_artifacts.txt
Error: Image build request failed with exit status 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  55.292 s
[INFO] Finished at: 2021-10-01T10:18:58-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.3.0.CR1:build (default) on project petstore: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR]         [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.RuntimeException: Failed to build native image
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:245)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
[ERROR]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:567)
[ERROR]         at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
[ERROR]         at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
[ERROR]         at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
[ERROR]         at java.base/java.lang.Thread.run(Thread.java:831)
[ERROR]         at org.jboss.threads.JBossThread.run(JBossThread.java:501)
[ERROR] Caused by: java.lang.RuntimeException: Image generation failed. Exit code: 1
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.imageGenerationFailed(NativeImageBuildStep.java:387)
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:215)
[ERROR]         ... 11 more
[ERROR] -> [Help 1]
[ERROR] 

@murphye
Copy link
Author

murphye commented Oct 1, 2021

Seems to be a related issue oracle/graal#3125

@murphye
Copy link
Author

murphye commented Oct 1, 2021

Ok, I got it working, but this isn't an ideal situation:

  1. Had to add @RegisterForReflection to the record
  2. Had to add --report-unsupported-elements-at-runtime to quarkus.native.additional-build-args

For a developer simply wanting to use a record in native mode, they shouldn't have to do either. Can you augment record objects at build time?

  1. Also improve stack trace logging for QuarkusJacksonJsonCodec to make it easier to find the original Jackson error.

@geoand
Copy link
Contributor

geoand commented Oct 1, 2021

Seems to be a related issue oracle/graal#3125

Indeed, that looks like the root cause.

FWIW, GraalVM doesn't have proper support for post Java 11 native image build just yet, but hopefully that will arrive soon.

@geoand
Copy link
Contributor

geoand commented Oct 1, 2021

Also improve stack trace logging for QuarkusJacksonJsonCodec to make it easier to find the original Jackson error.

#20510 should take care of it

@geoand
Copy link
Contributor

geoand commented Nov 8, 2021

I think we can close this in favor of #20891 which has more analysis by @zakkak

@geoand geoand closed this as completed Nov 8, 2021
@geoand geoand added the triage/duplicate This issue or pull request already exists label Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/jackson Issues related to Jackson (JSON library) kind/bug Something isn't working triage/duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants