6

此处提供的示例项目: https ://github.com/codependent/micronaut-aws-lambda-proxy-graal

我在 Amazon AWS 上部署了一个 Micronaut 应用程序作为 Lambda 函数。它被编译成 GraalVM 原生镜像并使用AWS Lambda Custom Runtime 运行

如果应用程序不使用 DynamoDB,它会顺利运行。当配置它并作为一个普通的 Java 应用程序启动时,它也可以正常工作。但是,当将其用作在 AWS 上运行的 Graal 本机映像时,它会失败并显示:

io.micronaut.context.exceptions.BeanInstantiationException:错误实例化类型为 [com.amazonaws.services.dynamodbv2.document.DynamoDB] 的 bean 消息:无法从 com/amazonaws/partitions/endpoints.json 加载分区元数据

我正在使用此依赖项:compile 'com.amazonaws:aws-java-sdk-dynamodb:1.11.504'

如何解决无法加载分区元数据错误?

完整日志:

Caused by: com.amazonaws.SdkClientException: Unable to load partition metadata from com/amazonaws/partitions/endpoints.json
at com.amazonaws.partitions.PartitionsLoader.build(PartitionsLoader.java:82)
at com.amazonaws.regions.RegionMetadataFactory.create(RegionMetadataFactory.java:30)
at com.amazonaws.regions.RegionUtils.initialize(RegionUtils.java:64)
at com.amazonaws.regions.RegionUtils.getRegionMetadata(RegionUtils.java:52)
at com.amazonaws.regions.RegionUtils.getRegion(RegionUtils.java:105)
at com.amazonaws.client.builder.AwsClientBuilder.getRegionObject(AwsClientBuilder.java:256)
at com.amazonaws.client.builder.AwsClientBuilder.withRegion(AwsClientBuilder.java:245)
at com.amazonaws.client.builder.AwsClientBuilder.withRegion(AwsClientBuilder.java:232)
at com.codependent.micronaut.awslambda.configuration.DynamoDbConfiguration.dynamoDbClient(DynamoDbConfiguration.kt:18)
at com.codependent.micronaut.awslambda.configuration.$DynamoDbConfiguration$DynamoDbClientDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1385)

更新:

我错过了以下异常的嵌套原因:Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of com.amazonaws.partitions.model.Partitions (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)

这是完整的堆栈跟踪:

START RequestId: c5998c1d-490b-4794-814e-82afbeb70fea Version: $LATEST
[36m23:10:58.905[0;39m [1;30m[main][0;39m [1;31mERROR[0;39m [35mi.m.f.a.p.AbstractLambdaContainerHandler[0;39m - Error while handling request
io.micronaut.context.exceptions.BeanInstantiationException: Error instantiating bean of type [com.amazonaws.services.dynamodbv2.document.DynamoDB]

Message: Error while loading partitions file from com/amazonaws/partitions/endpoints.json
Path Taken: new WarmUpController([PingService pingService]) --> new PingService([PingRepository pingRepository]) --> new PingRepository(Environment environment,[DynamoDB dynamoDb],DynamoDBMapper dynamoDbMapper) --> DynamoDB.dynamoDb([AmazonDynamoDB dynamoDbClient])
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1399)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1972)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1693)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1673)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:941)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:981)
at com.codependent.micronaut.awslambda.configuration.$DynamoDbConfiguration$DynamoDbDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1385)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1972)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1693)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1673)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:941)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:981)
at com.codependent.micronaut.awslambda.repository.$PingRepositoryDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1385)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1972)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1693)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1673)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:941)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:981)
at com.codependent.micronaut.awslambda.service.$PingServiceDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1385)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1972)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1693)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1673)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:941)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:981)
at com.codependent.micronaut.awslambda.web.$WarmUpControllerDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1385)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1972)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1693)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1673)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:550)
at io.micronaut.context.DefaultBeanContext$BeanExecutionHandle.getTarget(DefaultBeanContext.java:2522)
at io.micronaut.context.DefaultBeanContext$BeanExecutionHandle.invoke(DefaultBeanContext.java:2543)
at io.micronaut.web.router.AbstractRouteMatch.execute(AbstractRouteMatch.java:236)
at io.micronaut.web.router.RouteMatch.execute(RouteMatch.java:122)
at io.micronaut.function.aws.proxy.MicronautLambdaContainerHandler.lambda$null$1(MicronautLambdaContainerHandler.java:240)
at io.reactivex.internal.operators.flowable.FlowableDefer.subscribeActual(FlowableDefer.java:35)
at io.reactivex.Flowable.subscribe(Flowable.java:14805)
at io.reactivex.Flowable.subscribe(Flowable.java:14752)
at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:68)
at io.reactivex.Flowable.subscribe(Flowable.java:14805)
at io.reactivex.Flowable.subscribe(Flowable.java:14752)
at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run(FlowableSubscribeOn.java:82)
at io.micronaut.http.context.ServerRequestContext.with(ServerRequestContext.java:52)
at io.micronaut.http.context.ServerRequestContext.lambda$instrument$0(ServerRequestContext.java:68)
at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker$BooleanRunnable.run(ExecutorScheduler.java:288)
at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker.run(ExecutorScheduler.java:253)
at io.micronaut.http.context.ServerRequestContext.with(ServerRequestContext.java:52)
at io.micronaut.http.context.ServerRequestContext.lambda$instrument$0(ServerRequestContext.java:68)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at io.micronaut.http.context.ServerRequestContext.with(ServerRequestContext.java:52)
at io.micronaut.http.context.ServerRequestContext.lambda$instrument$0(ServerRequestContext.java:68)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:481)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
Caused by: com.amazonaws.SdkClientException: Error while loading partitions file from com/amazonaws/partitions/endpoints.json
at com.amazonaws.partitions.PartitionsLoader.loadPartitionFromStream(PartitionsLoader.java:95)
at com.amazonaws.partitions.PartitionsLoader.build(PartitionsLoader.java:84)
at com.amazonaws.regions.RegionMetadataFactory.create(RegionMetadataFactory.java:30)
at com.amazonaws.regions.RegionUtils.initialize(RegionUtils.java:64)
at com.amazonaws.regions.RegionUtils.getRegionMetadata(RegionUtils.java:52)
at com.amazonaws.regions.RegionUtils.getRegion(RegionUtils.java:105)
at com.amazonaws.client.builder.AwsClientBuilder.getRegionObject(AwsClientBuilder.java:256)
at com.amazonaws.client.builder.AwsClientBuilder.withRegion(AwsClientBuilder.java:245)
at com.amazonaws.client.builder.AwsClientBuilder.withRegion(AwsClientBuilder.java:232)
at com.codependent.micronaut.awslambda.configuration.DynamoDbConfiguration.dynamoDbClient(DynamoDbConfiguration.kt:18)
at com.codependent.micronaut.awslambda.configuration.$DynamoDbConfiguration$DynamoDbClientDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1385)
... 57 common frames omitted
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.amazonaws.partitions.model.Partitions` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: (ByteArrayInputStream); line: 2, column: 3]
at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1452)
at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1028)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1297)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:326)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:159)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3070)
at com.amazonaws.partitions.PartitionsLoader.loadPartitionFromStream(PartitionsLoader.java:92)
... 68 common frames omitted
[36m23:10:58.905[0;39m [1;30m[main][0;39m [1;31mERROR[0;39m [35mc.a.s.proxy.AwsProxyExceptionHandler[0;39m - Called exception handler for:
io.micronaut.context.exceptions.BeanInstantiationException: Error instantiating bean of type [com.amazonaws.services.dynamodbv2.document.DynamoDB]

Message: Error while loading partitions file from com/amazonaws/partitions/endpoints.json
Path Taken: new WarmUpController([PingService pingService]) --> new PingService([PingRepository pingRepository]) --> new PingRepository(Environment environment,[DynamoDB dynamoDb],DynamoDBMapper dynamoDbMapper) --> DynamoDB.dynamoDb([AmazonDynamoDB dynamoDbClient])
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1399)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1972)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1693)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1673)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:941)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:981)
at com.codependent.micronaut.awslambda.configuration.$DynamoDbConfiguration$DynamoDbDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1385)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1972)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1693)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1673)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:941)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:981)
at com.codependent.micronaut.awslambda.repository.$PingRepositoryDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1385)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1972)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1693)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1673)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:941)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:981)
at com.codependent.micronaut.awslambda.service.$PingServiceDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1385)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1972)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1693)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1673)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:941)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:981)
at com.codependent.micronaut.awslambda.web.$WarmUpControllerDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1385)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1972)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1693)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1673)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:550)
at io.micronaut.context.DefaultBeanContext$BeanExecutionHandle.getTarget(DefaultBeanContext.java:2522)
at io.micronaut.context.DefaultBeanContext$BeanExecutionHandle.invoke(DefaultBeanContext.java:2543)
at io.micronaut.web.router.AbstractRouteMatch.execute(AbstractRouteMatch.java:236)
at io.micronaut.web.router.RouteMatch.execute(RouteMatch.java:122)
at io.micronaut.function.aws.proxy.MicronautLambdaContainerHandler.lambda$null$1(MicronautLambdaContainerHandler.java:240)
at io.reactivex.internal.operators.flowable.FlowableDefer.subscribeActual(FlowableDefer.java:35)
at io.reactivex.Flowable.subscribe(Flowable.java:14805)
at io.reactivex.Flowable.subscribe(Flowable.java:14752)
at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:68)
at io.reactivex.Flowable.subscribe(Flowable.java:14805)
at io.reactivex.Flowable.subscribe(Flowable.java:14752)
at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run(FlowableSubscribeOn.java:82)
at io.micronaut.http.context.ServerRequestContext.with(ServerRequestContext.java:52)
at io.micronaut.http.context.ServerRequestContext.lambda$instrument$0(ServerRequestContext.java:68)
at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker$BooleanRunnable.run(ExecutorScheduler.java:288)
at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker.run(ExecutorScheduler.java:253)
at io.micronaut.http.context.ServerRequestContext.with(ServerRequestContext.java:52)
at io.micronaut.http.context.ServerRequestContext.lambda$instrument$0(ServerRequestContext.java:68)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at io.micronaut.http.context.ServerRequestContext.with(ServerRequestContext.java:52)
at io.micronaut.http.context.ServerRequestContext.lambda$instrument$0(ServerRequestContext.java:68)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:481)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
Caused by: com.amazonaws.SdkClientException: Error while loading partitions file from com/amazonaws/partitions/endpoints.json
at com.amazonaws.partitions.PartitionsLoader.loadPartitionFromStream(PartitionsLoader.java:95)
at com.amazonaws.partitions.PartitionsLoader.build(PartitionsLoader.java:84)
at com.amazonaws.regions.RegionMetadataFactory.create(RegionMetadataFactory.java:30)
at com.amazonaws.regions.RegionUtils.initialize(RegionUtils.java:64)
at com.amazonaws.regions.RegionUtils.getRegionMetadata(RegionUtils.java:52)
at com.amazonaws.regions.RegionUtils.getRegion(RegionUtils.java:105)
at com.amazonaws.client.builder.AwsClientBuilder.getRegionObject(AwsClientBuilder.java:256)
at com.amazonaws.client.builder.AwsClientBuilder.withRegion(AwsClientBuilder.java:245)
at com.amazonaws.client.builder.AwsClientBuilder.withRegion(AwsClientBuilder.java:232)
at com.codependent.micronaut.awslambda.configuration.DynamoDbConfiguration.dynamoDbClient(DynamoDbConfiguration.kt:18)
at com.codependent.micronaut.awslambda.configuration.$DynamoDbConfiguration$DynamoDbClientDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1385)
... 57 common frames omitted
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.amazonaws.partitions.model.Partitions` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: (ByteArrayInputStream); line: 2, column: 3]
at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1452)
at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1028)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1297)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:326)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:159)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3070)
at com.amazonaws.partitions.PartitionsLoader.loadPartitionFromStream(PartitionsLoader.java:92)
... 68 common frames omitted
io.micronaut.context.exceptions.BeanInstantiationException: Error instantiating bean of type [com.amazonaws.services.dynamodbv2.document.DynamoDB]

Message: Error while loading partitions file from com/amazonaws/partitions/endpoints.json
Path Taken: new WarmUpController([PingService pingService]) --> new PingService([PingRepository pingRepository]) --> new PingRepository(Environment environment,[DynamoDB dynamoDb],DynamoDBMapper dynamoDbMapper) --> DynamoDB.dynamoDb([AmazonDynamoDB dynamoDbClient])
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1399)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1972)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1693)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1673)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:941)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:981)
at com.codependent.micronaut.awslambda.configuration.$DynamoDbConfiguration$DynamoDbDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1385)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1972)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1693)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1673)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:941)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:981)
at com.codependent.micronaut.awslambda.repository.$PingRepositoryDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1385)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1972)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1693)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1673)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:941)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:981)
at com.codependent.micronaut.awslambda.service.$PingServiceDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1385)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1972)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1693)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1673)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:941)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:981)
at com.codependent.micronaut.awslambda.web.$WarmUpControllerDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1385)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1972)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1693)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1673)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:550)
at io.micronaut.context.DefaultBeanContext$BeanExecutionHandle.getTarget(DefaultBeanContext.java:2522)
at io.micronaut.context.DefaultBeanContext$BeanExecutionHandle.invoke(DefaultBeanContext.java:2543)
at io.micronaut.web.router.AbstractRouteMatch.execute(AbstractRouteMatch.java:236)
at io.micronaut.web.router.RouteMatch.execute(RouteMatch.java:122)
at io.micronaut.function.aws.proxy.MicronautLambdaContainerHandler.lambda$null$1(MicronautLambdaContainerHandler.java:240)
at io.reactivex.internal.operators.flowable.FlowableDefer.subscribeActual(FlowableDefer.java:35)
at io.reactivex.Flowable.subscribe(Flowable.java:14805)
at io.reactivex.Flowable.subscribe(Flowable.java:14752)
at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:68)
at io.reactivex.Flowable.subscribe(Flowable.java:14805)
at io.reactivex.Flowable.subscribe(Flowable.java:14752)
at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run(FlowableSubscribeOn.java:82)
at io.micronaut.http.context.ServerRequestContext.with(ServerRequestContext.java:52)
at io.micronaut.http.context.ServerRequestContext.lambda$instrument$0(ServerRequestContext.java:68)
at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker$BooleanRunnable.run(ExecutorScheduler.java:288)
at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker.run(ExecutorScheduler.java:253)
at io.micronaut.http.context.ServerRequestContext.with(ServerRequestContext.java:52)
at io.micronaut.http.context.ServerRequestContext.lambda$instrument$0(ServerRequestContext.java:68)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at io.micronaut.http.context.ServerRequestContext.with(ServerRequestContext.java:52)
at io.micronaut.http.context.ServerRequestContext.lambda$instrument$0(ServerRequestContext.java:68)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:481)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
Caused by: com.amazonaws.SdkClientException: Error while loading partitions file from com/amazonaws/partitions/endpoints.json
at com.amazonaws.partitions.PartitionsLoader.loadPartitionFromStream(PartitionsLoader.java:95)
at com.amazonaws.partitions.PartitionsLoader.build(PartitionsLoader.java:84)
at com.amazonaws.regions.RegionMetadataFactory.create(RegionMetadataFactory.java:30)
at com.amazonaws.regions.RegionUtils.initialize(RegionUtils.java:64)
at com.amazonaws.regions.RegionUtils.getRegionMetadata(RegionUtils.java:52)
at com.amazonaws.regions.RegionUtils.getRegion(RegionUtils.java:105)
at com.amazonaws.client.builder.AwsClientBuilder.getRegionObject(AwsClientBuilder.java:256)
at com.amazonaws.client.builder.AwsClientBuilder.withRegion(AwsClientBuilder.java:245)
at com.amazonaws.client.builder.AwsClientBuilder.withRegion(AwsClientBuilder.java:232)
at com.codependent.micronaut.awslambda.configuration.DynamoDbConfiguration.dynamoDbClient(DynamoDbConfiguration.kt:18)
at com.codependent.micronaut.awslambda.configuration.$DynamoDbConfiguration$DynamoDbClientDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1385)
... 57 more
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.amazonaws.partitions.model.Partitions` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: (ByteArrayInputStream); line: 2, column: 3]
at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1452)
at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1028)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1297)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:326)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:159)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3070)
at com.amazonaws.partitions.PartitionsLoader.loadPartitionFromStream(PartitionsLoader.java:92)
... 68 more
END RequestId: c5998c1d-490b-4794-814e-82afbeb70fea
REPORT RequestId: c5998c1d-490b-4794-814e-82afbeb70fea Duration: 107.89 ms Billed Duration: 200 ms Memory Size: 128 MB Max Memory Used: 59 MB 

更新 2:

我还尝试在 reflect.json 中为 Partitions 类添加一个条目:

...
}, {
  "name" : "com.amazonaws.partitions.model.Partitions",
  "allPublicMethods" : true,
  "allDeclaredConstructors" : true
}]
4

3 回答 3

8

由于这个 Graal Github issue的指示,这终于解决了。

加起来:

  1. -H:IncludeResources="logback.xml|application.yml|com/amazonaws/partitions/endpoints.json".

  2. 在 reflect.json 中添加这些条目:

反射.json:

 , {
  "name" : "com.amazonaws.partitions.model.Partitions",
  "allPublicMethods" : true,
  "allDeclaredConstructors" : true
}, {
  "name" : "com.amazonaws.partitions.model.Partition",
  "allPublicMethods" : true,
  "allDeclaredConstructors" : true
}, {
  "name" : "com.amazonaws.partitions.model.Endpoint",
  "allPublicMethods" : true,
  "allDeclaredConstructors" : true
}, {
  "name" : "com.amazonaws.partitions.model.Region",
  "allPublicMethods" : true,
  "allDeclaredConstructors" : true
}, {
  "name" : "com.amazonaws.partitions.model.Service",
  "allPublicMethods" : true,
  "allDeclaredConstructors" : true
}, {
  "name" : "com.amazonaws.partitions.model.CredentialScope",
  "allPublicMethods" : true,
  "allDeclaredConstructors" : true
}, {
  "name" : "java.util.HashSet",
  "allPublicMethods" : true,
  "allDeclaredConstructors" : true
}
于 2019-03-03T02:06:53.973 回答
1

静态资源不会自动包含在本机映像中。您可能必须修改本机图像命令以com/amazonaws/partitions/endpoints.json包含-H:IncludeResources

于 2019-02-28T19:58:54.307 回答
1

如果可以,您应该升级到 AWS SDK v2。升级后的库解决了大部分问题,您几乎不需要进行任何配置即可使其工作。

几乎让 AWS SDK v1 工作,然后我意识到我使用了错误的依赖项。

在我的 build.gradle 依赖块中,我放了这些,它开箱即用:

   implementation platform("software.amazon.awssdk:bom:2.17.+")
   implementation "io.micronaut.aws:micronaut-aws-sdk-v2:3.0.+"
   implementation "software.amazon.awssdk:lambda"
于 2021-12-07T17:26:03.883 回答