micronaut-projects / micronaut-aws

Projects specific to integrating Micronaut and Amazon Web Services (AWS)
Apache License 2.0
85 stars 79 forks source link

AWS Lambda SDK Request_Response failing on GraalVM Image #495

Open msandy10 opened 4 years ago

msandy10 commented 4 years ago

Hi Team, I have recently upgraded Micronauts from 1.1.1 to 1.3.6 and AWS SDK Lambda 2 with GraalVM Native image, we are invoking other lambda function endpoint using request_response type and capturing in below model ResponsePayload

GraalVM 19.2.1 Native Image getting generated but aws sdk call not working and GraalVM 20.0.0 native image generation error

Environment Information

Task List

1599204222653,"java.lang.RuntimeException: com.test.exception.CustomException: Error parsing lambda invoke response: Cannot construct instance of com.test.connector.ResponsePayload (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator) " 1599204222653,"at [Source: (String)""{""statusCode"":404,""multiValueHeaders"":{},""isBase64Encoded"":false}""; line: 1, column: 2] " 1599204222654,"at io.reactivex.internal.util.ExceptionHelper.wrapOrThrow(ExceptionHelper.java:46) " 1599204222654,"at io.reactivex.internal.subscribers.BlockingBaseSubscriber.blockingGet(BlockingBaseSubscriber.java:78) " 1599204222654,"at io.reactivex.Flowable.blockingFirst(Flowable.java:5699) " 1599204222654,"at io.micronaut.function.aws.proxy.MicronautLambdaContainerHandler.lambda$handleRequest$7(MicronautLambdaContainerHandler.java:334) " 1599204222654,"at io.micronaut.http.context.ServerRequestContext.with(ServerRequestContext.java:68) " 1599204222654,"at io.micronaut.function.aws.proxy.MicronautLambdaContainerHandler.handleRequest(MicronautLambdaContainerHandler.java:265) " 1599204222654,"at io.micronaut.function.aws.proxy.MicronautLambdaContainerHandler.handleRequest(MicronautLambdaContainerHandler.java:80) " 1599204222654,"at io.micronaut.function.aws.proxy.AbstractLambdaContainerHandler.proxy(AbstractLambdaContainerHandler.java:207) " 1599204222654,"at io.micronaut.function.aws.runtime.MicronautLambdaRuntime.startRuntimeApiEventLoop(MicronautLambdaRuntime.java:131) " 1599204222654,"at io.micronaut.function.aws.runtime.MicronautLambdaRuntime.main(MicronautLambdaRuntime.java:77) " 1599204222654,"Caused by: com.test.exception.CustomException: Error parsing lambda invoke response: Cannot construct instance of com.test.connector.ResponsePayload (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator) " 1599204222654,"at [Source: (String)""{""statusCode"":404,""multiValueHeaders"":{},""isBase64Encoded"":false}""; line: 1, column: 2] " 1599204222654,"at com.test.connector.EntitlementAwsSdkConnector.getSSOId(EntitlementAwsSdkConnector.java:113) " 1599204222654,"at com.test.service.TestService.getIdp(TestService.java:15) " 1599204222654,"at com.test.controller.TestController.getIdp(TestController.java:25) " 1599204222654,"at com.test.controller.$TestControllerDefinition$Intercepted.$$access0(Unknown Source) " 1599204222654,"at com.test.controller.$TestControllerDefinition$Intercepted$$proxy0.invokeInternal(Unknown Source) " 1599204222654,"at io.micronaut.context.AbstractExecutableMethod.invoke(AbstractExecutableMethod.java:146) " 1599204222654,"at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:60) " 1599204222654,"at io.micronaut.validation.ValidatingInterceptor.intercept(ValidatingInterceptor.java:123) " 1599204222654,"at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:69) " 1599204222654,"at com.test.controller.$TestControllerDefinition$Intercepted.getIdp(Unknown Source) " 1599204222654,"at com.test.controller.$$TestControllerDefinition$InterceptedDefinition$$exec1.invokeInternal(Unknown Source) " 1599204222654,"at io.micronaut.context.AbstractExecutableMethod.invoke(AbstractExecutableMethod.java:146) " 1599204222654,"at io.micronaut.context.DefaultBeanContext$BeanExecutionHandle.invoke(DefaultBeanContext.java:3016) " 1599204222654,"at io.micronaut.web.router.AbstractRouteMatch.execute(AbstractRouteMatch.java:286) " 1599204222654,"at io.micronaut.web.router.RouteMatch.execute(RouteMatch.java:122) " 1599204222654,"at io.micronaut.function.aws.proxy.MicronautLambdaContainerHandler.executeRoute(MicronautLambdaContainerHandler.java:418) " 1599204222654,"at io.micronaut.function.aws.proxy.MicronautLambdaContainerHandler.lambda$null$4(MicronautLambdaContainerHandler.java:294) " 1599204222654,"at io.reactivex.internal.operators.flowable.FlowableDefer.subscribeActual(FlowableDefer.java:35) " 1599204222654,"at io.reactivex.Flowable.subscribe(Flowable.java:14935) " 1599204222654,"at io.reactivex.Flowable.subscribe(Flowable.java:14882) " 1599204222654,"at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:58) " 1599204222654,"at io.reactivex.Flowable.subscribe(Flowable.java:14935) " 1599204222654,"at io.reactivex.Flowable.subscribe(Flowable.java:14882) " 1599204222654,"at io.micronaut.http.server.context.ServerRequestContextFilter$1.subscribe(ServerRequestContextFilter.java:66) " 1599204222654,"at io.reactivex.internal.operators.flowable.FlowableFromPublisher.subscribeActual(FlowableFromPublisher.java:29) " 1599204222654,"at io.reactivex.Flowable.subscribe(Flowable.java:14935) " 1599204222654,"at io.reactivex.Flowable.subscribe(Flowable.java:14882) " 1599204222654,"at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:58) " 1599204222654,"at io.reactivex.Flowable.subscribe(Flowable.java:14935) " 1599204222654,"at io.reactivex.internal.operators.flowable.FlowableOnErrorNext.subscribeActual(FlowableOnErrorNext.java:40) " 1599204222654,"at io.reactivex.Flowable.subscribe(Flowable.java:14935) " 1599204222654,"at io.reactivex.Flowable.subscribe(Flowable.java:14882) " 1599204222654,"at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:58) " 1599204222654,"at io.reactivex.Flowable.subscribe(Flowable.java:14935) " 1599204222654,"at io.reactivex.Flowable.blockingFirst(Flowable.java:5698) " 1599204222654,"... 7 more " 1599204222661,"END RequestId: 34dd9750-1b30-4798-b1d3-c9ef998f30a6 " 1599204222661,"REPORT RequestId: 34dd9750-1b30-4798-b1d3-c9ef998f30a6 Duration: 1560.12 ms Billed Duration: 2400 ms Memory Size: 2944 MB Max Memory Used: 140 MB Init Duration: 741.38 ms
"

- [ ] If we try to generate Native Image with GraalVM 20.0.0 we are getting below error message

---> 0ca77393c069 Step 5/14 : FROM graalvm_20.0.0 ---> 4dd11dd9df72 Step 6/14 : COPY --from=builder /home/application/ /home/application/ ---> 883b9d6e43ce Step 7/14 : WORKDIR /home/application ---> Running in 9f624374b04b Removing intermediate container 9f624374b04b ---> 9266c2a08d81 Step 8/14 : RUN /usr/lib/graalvm/bin/gu install native-image ---> Running in 4addaf4540c8 Downloading: Component catalog from www.graalvm.org Processing Component: Native Image Downloading: Component native-image: Native Image from github.com Installing new component: Native Image (org.graalvm.native-image, version 20.0.0) Removing intermediate container 4addaf4540c8 ---> 5f1979bb5c01 Step 9/14 : RUN /usr/lib/graalvm/bin/native-image -J-Xmx6G -J-Xms4G --no-server -H:+ReportExceptionStackTraces --class-path build/libs/test-function-custom-runtime-0.1-all.jar ---> Running in 1cf8a2a852ad [server:22] classlist: 22,370.55 ms, 5.34 GB [server:22] (cap): 2,247.62 ms, 5.48 GB [server:22] setup: 6,268.40 ms, 5.48 GB Printing initializer configuration to /home/application/reports/initializer_configuration_20200904_074722.txt Printing initializer configuration to /home/application/reports/initializer_configuration_20200904_074814.txt [Use -Dgraal.LogFile= to redirect Graal log output to a file.] [thread:18] scope: ForkJoinPool-4-worker-1 [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/io.micronaut.http.HttpRequestFactory [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/com.fasterxml.jackson.core.ObjectCodec [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/io.micronaut.core.beans.BeanIntrospectionReference [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/com.fasterxml.jackson.core.JsonFactory [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/com.fasterxml.jackson.databind.Module [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/org.slf4j.spi.SLF4JServiceProvider [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/io.micronaut.inject.BeanDefinitionReference [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/io.micronaut.inject.BeanConfiguration [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/io.micronaut.context.env.PropertySourceLoader [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/java.nio.file.spi.FileSystemProvider [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/io.micronaut.http.HttpResponseFactory [thread:18] scope: ForkJoinPool-4-worker-1.registerResource Resources have been added by ServiceLoaderFeature. Automatic registration can be disabled with -H:-UseServiceLoaderFeature [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/java.sql.Driver [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/org.mariadb.jdbc.credential.CredentialPlugin [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/org.mariadb.jdbc.tls.TlsSocketPlugin [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/org.mariadb.jdbc.authentication.AuthenticationPlugin [thread:18] scope: ForkJoinPool-4-worker-1.registerResource Resources have been added by ServiceLoaderFeature. Automatic registration can be disabled with -H:-UseServiceLoaderFeature [thread:30] scope: ForkJoinPool-2-worker-2 [thread:30] scope: ForkJoinPool-2-worker-2.ClosedWorldAnalysis Context: StructuredGraph:85454{AnalysisMethod<software.amazon.awssdk.protocols.json.internal.unmarshall.JsonProtocolUnmarshaller.createUnmarshallerRegistry -> HotSpotMethod<JsonProtocolUnmarshaller.createUnmarshallerRegistry(StringToValueConverter$StringToValue)>>} Context: AnalysisMethod<software.amazon.awssdk.protocols.json.internal.unmarshall.JsonProtocolUnmarshaller.createUnmarshallerRegistry -> HotSpotMethod<JsonProtocolUnmarshaller.createUnmarshallerRegistry(StringToValueConverter$StringToValue)>> [thread:30] scope: ForkJoinPool-2-worker-2.ClosedWorldAnalysis.AnalysisGraphBuilderPhase Exception raised in scope ForkJoinPool-2-worker-2.ClosedWorldAnalysis.AnalysisGraphBuilderPhase: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: No instances of software.amazon.awssdk.protocols.core.StringToValueConverter$$Lambda$9/1553399491 are allowed in the image heap as this class should be initialized at image runtime. Object has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. at parsing software.amazon.awssdk.protocols.json.internal.unmarshall.JsonProtocolUnmarshaller.createUnmarshallerRegistry(JsonProtocolUnmarshaller.java:78) at org.graalvm.compiler.java.BytecodeParser.throwParserError(BytecodeParser.java:2582) at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.throwParserError(SharedGraphBuilderPhase.java:94) at org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3402) at org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3204) at org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1085) at org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:979) at org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:84) at org.graalvm.compiler.phases.Phase.run(Phase.java:49) at org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:197) at org.graalvm.compiler.phases.Phase.apply(Phase.java:42) at org.graalvm.compiler.phases.Phase.apply(Phase.java:38) at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:221) at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:340) at com.oracle.graal.pointsto.flow.MethodTypeFlow.doParse(MethodTypeFlow.java:310) at com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureParsed(MethodTypeFlow.java:300) at com.oracle.graal.pointsto.flow.MethodTypeFlow.addContext(MethodTypeFlow.java:107) at com.oracle.graal.pointsto.flow.StaticInvokeTypeFlow.update(InvokeTypeFlow.java:346) at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:511) at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:171) at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: No instances of software.amazon.awssdk.protocols.core.StringToValueConverter$$Lambda$9/1553399491 are allowed in the image heap as this class should be initialized at image runtime. Object has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.checkImageHeapInstance(ClassInitializationFeature.java:173) at com.oracle.graal.pointsto.meta.AnalysisUniverse.replaceObject(AnalysisUniverse.java:534) at com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.replaceObject(AnalysisConstantReflectionProvider.java:201) at com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.interceptValue(AnalysisConstantReflectionProvider.java:172) at com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.readValue(AnalysisConstantReflectionProvider.java:101) at com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.readFieldValue(AnalysisConstantReflectionProvider.java:77) at org.graalvm.compiler.nodes.util.ConstantFoldUtil$1.readValue(ConstantFoldUtil.java:51) at org.graalvm.compiler.core.common.spi.JavaConstantFieldProvider.readConstantField(JavaConstantFieldProvider.java:84) at com.oracle.svm.hosted.ameta.AnalysisConstantFieldProvider.readConstantField(AnalysisConstantFieldProvider.java:72) at org.graalvm.compiler.nodes.util.ConstantFoldUtil.tryConstantFold(ConstantFoldUtil.java:47) at com.oracle.svm.hosted.phases.ConstantFoldLoadFieldPlugin.tryConstantFold(ConstantFoldLoadFieldPlugin.java:64) at com.oracle.svm.hosted.phases.ConstantFoldLoadFieldPlugin.handleLoadStaticField(ConstantFoldLoadFieldPlugin.java:60) at org.graalvm.compiler.java.BytecodeParser.genGetStatic(BytecodeParser.java:4830) at org.graalvm.compiler.java.BytecodeParser.genGetStatic(BytecodeParser.java:4797) at org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5282) at org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3397) ... 21 more

Context obj com.oracle.svm.hosted.phases.AnalysisGraphBuilderPhase@4eb3e64f
Context obj StructuredGraph:85454{AnalysisMethod<software.amazon.awssdk.protocols.json.internal.unmarshall.JsonProtocolUnmarshaller.createUnmarshallerRegistry -> HotSpotMethod<JsonProtocolUnmarshaller.createUnmarshallerRegistry(StringToValueConverter$StringToValue)>>}
Context obj AnalysisMethod<software.amazon.awssdk.protocols.json.internal.unmarshall.JsonProtocolUnmarshaller.createUnmarshallerRegistry -> HotSpotMethod<JsonProtocolUnmarshaller.createUnmarshallerRegistry(StringToValueConverter$StringToValue)>>
Context obj com.oracle.svm.hosted.analysis.flow.SVMMethodTypeFlowBuilder@5a052fb5

[server:22] analysis: 181,564.94 ms, 5.68 GB Error: Classes that should be initialized at run time got initialized during image building: software.amazon.awssdk.protocols.core.StringToValueConverter$SimpleStringToValue was unintentionally initialized at build time. software.amazon.awssdk.protocols.core.StringToValueConverter caused initialization of this class with the following trace: at software.amazon.awssdk.protocols.core.StringToValueConverter$SimpleStringToValue.(StringToValueConverter.java) at sun.misc.Unsafe.ensureClassInitialized(Native Method) at java.lang.invoke.DirectMethodHandle$EnsureInitialized.computeValue(DirectMethodHandle.java:330) at java.lang.invoke.DirectMethodHandle$EnsureInitialized.computeValue(DirectMethodHandle.java:327) at java.lang.ClassValue.getFromHashMap(ClassValue.java:227) at java.lang.ClassValue.getFromBackup(ClassValue.java:209) at java.lang.ClassValue.get(ClassValue.java:115) at java.lang.invoke.DirectMethodHandle.checkInitialized(DirectMethodHandle.java:351) at java.lang.invoke.DirectMethodHandle.ensureInitialized(DirectMethodHandle.java:341) at java.lang.invoke.DirectMethodHandle.ensureInitialized(DirectMethodHandle.java:373) at software.amazon.awssdk.protocols.core.StringToValueConverter.(StringToValueConverter.java:73)

software.amazon.awssdk.protocols.core.StringToValueConverter$$Lambda$9/1553399491 was unintentionally initialized at build time. software.amazon.awssdk.protocols.core.StringToValueConverter$$Lambda$9/1553399491 has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=software.amazon.awssdk.protocols.core.StringToValueConverter$$Lambda$9/1553399491

com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building: software.amazon.awssdk.protocols.core.StringToValueConverter$SimpleStringToValue was unintentionally initialized at build time. software.amazon.awssdk.protocols.core.StringToValueConverter caused initialization of this class with the following trace: at software.amazon.awssdk.protocols.core.StringToValueConverter$SimpleStringToValue.(StringToValueConverter.java) at sun.misc.Unsafe.ensureClassInitialized(Native Method) at java.lang.invoke.DirectMethodHandle$EnsureInitialized.computeValue(DirectMethodHandle.java:330) at java.lang.invoke.DirectMethodHandle$EnsureInitialized.computeValue(DirectMethodHandle.java:327) at java.lang.ClassValue.getFromHashMap(ClassValue.java:227) at java.lang.ClassValue.getFromBackup(ClassValue.java:209) at java.lang.ClassValue.get(ClassValue.java:115) at java.lang.invoke.DirectMethodHandle.checkInitialized(DirectMethodHandle.java:351) at java.lang.invoke.DirectMethodHandle.ensureInitialized(DirectMethodHandle.java:341) at java.lang.invoke.DirectMethodHandle.ensureInitialized(DirectMethodHandle.java:373) at software.amazon.awssdk.protocols.core.StringToValueConverter.(StringToValueConverter.java:73)

software.amazon.awssdk.protocols.core.StringToValueConverter$$Lambda$9/1553399491 was unintentionally initialized at build time. software.amazon.awssdk.protocols.core.StringToValueConverter$$Lambda$9/1553399491 has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=software.amazon.awssdk.protocols.core.StringToValueConverter$$Lambda$9/1553399491

    at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
    at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:510)
    at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:187)
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$8(NativeImageGenerator.java:715)
    at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:63)
    at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:715)
    at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:530)
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:445)
    at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

Error: Image build request failed with exit status 1 The command '/bin/sh -c /usr/lib/graalvm/bin/native-image -J-Xmx6G -J-Xms4G --no-server -H:+ReportExceptionStackTraces --class-path build/libs/user-function-custom-runtime-0.1-all.jar' returned a non-zero code: 1


### Expected Behaviour

- Native Image has work on Lambda and able to call other lambda with aws lambda sdk apis

### Actual Behaviour

Native Image has working on Lambda but getting error 

599204222654,"Caused by: com.test.exception.CustomException: Error parsing lambda invoke response: Cannot construct instance of com.test.connector.ResponsePayload (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator) " 1599204222654,"at [Source: (String)""{""statusCode"":404,""multiValueHeaders"":{},""isBase64Encoded"":false}""; line: 1, column: 2] "

msandy10 commented 4 years ago

Observed that Jackson Mapper mapper.writeValueAsString(request) are not working in GraalVM, it converted object to json like {} instead of {\"resource\":\"/resource\",\"path\":\"/path",\"httpMethod\":\"GET\",\"multiValueQueryStringParameters\":{\"email\":\"user_email@test.com\"}} thats why aws sdk lambda giving json response {""statusCode"":404,""multiValueHeaders"":{},""isBase64Encoded"":false}

code snapshot

        RequestPayload request = new RequestPayload(resource, path, GET_METHOD, null, null, queryParams, null, null);
        String lambdaRequest = "{\"resource\":\"/resource\",\"path\":\"/path\",\"httpMethod\":\"GET\",\"multiValueQueryStringParameters\":{\"email\":\"shandesh_madarpalle@trimble.com\"}}";
//      SdkBytes payload = SdkBytes.fromUtf8String(mapper.writeValueAsString(ssoidRequest)) ;
        SdkBytes payload = SdkBytes.fromUtf8String(ssoidRequest) ;
        InvokeRequest invokeRequest = InvokeRequest.builder()
                .functionName(entitlementFunction)
                .invocationType(InvocationType.REQUEST_RESPONSE)
                .payload(payload)
                .build();
        InvokeResponse response = lambdaClient.invoke(invokeRequest);

any Jackson configuration need procide for GraalVM?

graemerocher commented 4 years ago

Please upload an example that reproduces the problem

msandy10 commented 4 years ago

Step 21/26 : RUN /usr/lib/graalvm/bin/native-image --no-server -cp build/libs/my-aws-api-graal-native-image-*-all.jar ---> Running in 8eeb26573c51 [server:23] classlist: 125,552.41 ms [server:23] (cap): 3,878.51 ms [server:23] setup: 6,803.05 ms Printing initializer configuration to /home/application/reports/initializer_configuration_20200905_061759.txt [Use -Dgraal.LogFile= to redirect Graal log output to a file.] [thread:18] scope: ForkJoinPool-4-worker-1 [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ResourcesFeature: registerResource: META-INF/http/mime.types [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ResourcesFeature: registerResource: git.properties [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ResourcesFeature: registerResource: logback.xml [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/io.micronaut.http.HttpRequestFactory [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/com.fasterxml.jackson.core.ObjectCodec [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/org.slf4j.spi.SLF4JServiceProvider [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/io.micronaut.core.beans.BeanIntrospectionReference [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/com.fasterxml.jackson.core.JsonFactory [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/com.fasterxml.jackson.databind.Module [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/io.micronaut.inject.BeanConfiguration [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/io.micronaut.inject.BeanDefinitionReference [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/java.nio.file.spi.FileSystemProvider [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/io.micronaut.http.HttpResponseFactory [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/io.micronaut.context.env.PropertySourceLoader [thread:18] scope: ForkJoinPool-4-worker-1.registerResource Resources have been added by ServiceLoaderFeature. Automatic registration can be disabled with -H:-UseServiceLoaderFeature [thread:18] scope: ForkJoinPool-4-worker-1.registerResource ServiceLoaderFeature: registerResource: META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor [thread:18] scope: ForkJoinPool-4-worker-1.registerResource Resources have been added by ServiceLoaderFeature. Automatic registration can be disabled with -H:-UseServiceLoaderFeature [thread:24] scope: ForkJoinPool-2-worker-2 [thread:24] scope: ForkJoinPool-2-worker-2.ClosedWorldAnalysis Context: StructuredGraph:78814{AnalysisMethod<JsonProtocolUnmarshaller.createUnmarshallerRegistry -> HotSpotMethod<JsonProtocolUnmarshaller.createUnmarshallerRegistry(StringToValueConverter$StringToValue)>>} Context: AnalysisMethod<JsonProtocolUnmarshaller.createUnmarshallerRegistry -> HotSpotMethod<JsonProtocolUnmarshaller.createUnmarshallerRegistry(StringToValueConverter$StringToValue)>> [thread:24] scope: ForkJoinPool-2-worker-2.ClosedWorldAnalysis.AnalysisGraphBuilderPhase Exception raised in scope ForkJoinPool-2-worker-2.ClosedWorldAnalysis.AnalysisGraphBuilderPhase: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: No instances of software.amazon.awssdk.protocols.core.StringToValueConverter$$Lambda$6/132829124 are allowed in the image heap as this class should be initialized at image runtime. Object has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. at parsing software.amazon.awssdk.protocols.json.internal.unmarshall.JsonProtocolUnmarshaller.createUnmarshallerRegistry(JsonProtocolUnmarshaller.java:77) at org.graalvm.compiler.java.BytecodeParser.throwParserError(BytecodeParser.java:2475) at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.throwParserError(SharedGraphBuilderPhase.java:93) at org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3291) at org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3093) at org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:977) at org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:871) at org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:84) at org.graalvm.compiler.phases.Phase.run(Phase.java:49) at org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:197) at org.graalvm.compiler.phases.Phase.apply(Phase.java:42) at org.graalvm.compiler.phases.Phase.apply(Phase.java:38) at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:221) at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:340) at com.oracle.graal.pointsto.flow.MethodTypeFlow.doParse(MethodTypeFlow.java:310) at com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureParsed(MethodTypeFlow.java:300) at com.oracle.graal.pointsto.flow.MethodTypeFlow.addContext(MethodTypeFlow.java:107) at com.oracle.graal.pointsto.flow.StaticInvokeTypeFlow.update(InvokeTypeFlow.java:346) at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:511) at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:171) at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: No instances of software.amazon.awssdk.protocols.core.StringToValueConverter$$Lambda$6/132829124 are allowed in the image heap as this class should be initialized at image runtime. Object has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.checkImageHeapInstance(ClassInitializationFeature.java:173) at com.oracle.graal.pointsto.meta.AnalysisUniverse.replaceObject(AnalysisUniverse.java:534) at com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.replaceObject(AnalysisConstantReflectionProvider.java:201) at com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.interceptValue(AnalysisConstantReflectionProvider.java:172) at com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.readValue(AnalysisConstantReflectionProvider.java:101) at com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.readFieldValue(AnalysisConstantReflectionProvider.java:77) at org.graalvm.compiler.nodes.util.ConstantFoldUtil$1.readValue(ConstantFoldUtil.java:51) at org.graalvm.compiler.core.common.spi.JavaConstantFieldProvider.readConstantField(JavaConstantFieldProvider.java:84) at com.oracle.svm.hosted.ameta.AnalysisConstantFieldProvider.readConstantField(AnalysisConstantFieldProvider.java:72) at org.graalvm.compiler.nodes.util.ConstantFoldUtil.tryConstantFold(ConstantFoldUtil.java:47) at com.oracle.svm.hosted.phases.ConstantFoldLoadFieldPlugin.tryConstantFold(ConstantFoldLoadFieldPlugin.java:64) at com.oracle.svm.hosted.phases.ConstantFoldLoadFieldPlugin.handleLoadStaticField(ConstantFoldLoadFieldPlugin.java:60) at org.graalvm.compiler.java.BytecodeParser.genGetStatic(BytecodeParser.java:4712) at org.graalvm.compiler.java.BytecodeParser.genGetStatic(BytecodeParser.java:4679) at org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5164) at org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3286) ... 21 more

Context obj com.oracle.svm.hosted.phases.AnalysisGraphBuilderPhase@2efb5331
Context obj StructuredGraph:78814{AnalysisMethod<JsonProtocolUnmarshaller.createUnmarshallerRegistry -> HotSpotMethod<JsonProtocolUnmarshaller.createUnmarshallerRegistry(StringToValueConverter$StringToValue)>>}
Context obj AnalysisMethod<JsonProtocolUnmarshaller.createUnmarshallerRegistry -> HotSpotMethod<JsonProtocolUnmarshaller.createUnmarshallerRegistry(StringToValueConverter$StringToValue)>>
Context obj com.oracle.svm.hosted.analysis.flow.SVMMethodTypeFlowBuilder@2db7b953

[server:23] analysis: 203,903.10 ms Error: Classes that should be initialized at run time got initialized during image building: org.mariadb.jdbc.Driver was unintentionally initialized at build time. java.sql.DriverManager caused initialization of this class with the following trace: at org.mariadb.jdbc.Driver.(Driver.java) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at java.lang.Class.newInstance(Class.java:442) at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380) at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404) at java.util.ServiceLoader$1.next(ServiceLoader.java:480) at java.sql.DriverManager$2.run(DriverManager.java:603) at java.sql.DriverManager$2.run(DriverManager.java:583) at java.security.AccessController.doPrivileged(Native Method) at java.sql.DriverManager.loadInitialDrivers(DriverManager.java:583) at java.sql.DriverManager.(DriverManager.java:101)

software.amazon.awssdk.protocols.core.StringToValueConverter$SimpleStringToValue was unintentionally initialized at build time. software.amazon.awssdk.protocols.core.StringToValueConverter caused initialization of this class with the following trace: at software.amazon.awssdk.protocols.core.StringToValueConverter$SimpleStringToValue.(StringToValueConverter.java) at sun.misc.Unsafe.ensureClassInitialized(Native Method) at java.lang.invoke.DirectMethodHandle$EnsureInitialized.computeValue(DirectMethodHandle.java:330) at java.lang.invoke.DirectMethodHandle$EnsureInitialized.computeValue(DirectMethodHandle.java:327) at java.lang.ClassValue.getFromHashMap(ClassValue.java:227) at java.lang.ClassValue.getFromBackup(ClassValue.java:209) at java.lang.ClassValue.get(ClassValue.java:115) at java.lang.invoke.DirectMethodHandle.checkInitialized(DirectMethodHandle.java:351) at java.lang.invoke.DirectMethodHandle.ensureInitialized(DirectMethodHandle.java:341) at java.lang.invoke.DirectMethodHandle.ensureInitialized(DirectMethodHandle.java:373) at software.amazon.awssdk.protocols.core.StringToValueConverter.(StringToValueConverter.java:73)

software.amazon.awssdk.protocols.core.StringToValueConverter$$Lambda$6/132829124 was unintentionally initialized at build time. software.amazon.awssdk.protocols.core.StringToValueConverter$$Lambda$6/132829124 has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=software.amazon.awssdk.protocols.core.StringToValueConverter$$Lambda$6/132829124

com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building: org.mariadb.jdbc.Driver was unintentionally initialized at build time. java.sql.DriverManager caused initialization of this class with the following trace: at org.mariadb.jdbc.Driver.(Driver.java) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at java.lang.Class.newInstance(Class.java:442) at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380) at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404) at java.util.ServiceLoader$1.next(ServiceLoader.java:480) at java.sql.DriverManager$2.run(DriverManager.java:603) at java.sql.DriverManager$2.run(DriverManager.java:583) at java.security.AccessController.doPrivileged(Native Method) at java.sql.DriverManager.loadInitialDrivers(DriverManager.java:583) at java.sql.DriverManager.(DriverManager.java:101)

software.amazon.awssdk.protocols.core.StringToValueConverter$SimpleStringToValue was unintentionally initialized at build time. software.amazon.awssdk.protocols.core.StringToValueConverter caused initialization of this class with the following trace: at software.amazon.awssdk.protocols.core.StringToValueConverter$SimpleStringToValue.(StringToValueConverter.java) at sun.misc.Unsafe.ensureClassInitialized(Native Method) at java.lang.invoke.DirectMethodHandle$EnsureInitialized.computeValue(DirectMethodHandle.java:330) at java.lang.invoke.DirectMethodHandle$EnsureInitialized.computeValue(DirectMethodHandle.java:327) at java.lang.ClassValue.getFromHashMap(ClassValue.java:227) at java.lang.ClassValue.getFromBackup(ClassValue.java:209) at java.lang.ClassValue.get(ClassValue.java:115) at java.lang.invoke.DirectMethodHandle.checkInitialized(DirectMethodHandle.java:351) at java.lang.invoke.DirectMethodHandle.ensureInitialized(DirectMethodHandle.java:341) at java.lang.invoke.DirectMethodHandle.ensureInitialized(DirectMethodHandle.java:373) at software.amazon.awssdk.protocols.core.StringToValueConverter.(StringToValueConverter.java:73)

software.amazon.awssdk.protocols.core.StringToValueConverter$$Lambda$6/132829124 was unintentionally initialized at build time. software.amazon.awssdk.protocols.core.StringToValueConverter$$Lambda$6/132829124 has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=software.amazon.awssdk.protocols.core.StringToValueConverter$$Lambda$6/132829124

    at com.oracle.svm.core.util.UserError.abort(UserError.java:65)
    at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:510)
    at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:187)
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$8(NativeImageGenerator.java:710)
    at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:63)
    at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:710)
    at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:530)
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:445)
    at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

Error: Image build request failed with exit status 1 The command '/bin/sh -c /usr/lib/graalvm/bin/native-image --no-server -cp build/libs/my-aws-api-graal-native-image-*-all.jar' returned a non-zero code: 1

`

msandy10 commented 4 years ago

@graemerocher I have attached an example for a reproducing the issue, can you please have a look on code