AWS Lambda-将Spring Cloud Function与S3Event一起使用时出错

时间:2018-09-19 22:06:30

标签: amazon-web-services spring-boot aws-lambda spring-cloud

我正在尝试将Spring Cloud Function与AWS Lambda上的S3事件一起使用。我克隆了this repository,运行了mvn clean package,然后上传到了我的AWS账户(s3)。我遵循了设置说明,它似乎正在启动Spring Application,自动装配AWS S3 Client(AmazonS3),并且当我使用Test函数时,似乎正在调用该函数。但是,它在调用函数时出现,出现以下错误:

{
  "errorMessage": "java.util.LinkedHashMap cannot be cast to com.amazonaws.services.lambda.runtime.events.S3Event",
  "errorType": "java.lang.ClassCastException",
  "stackTrace": [
    "com.mj.aws.lambda.s3.AwsLambdaS3Function.apply(AwsLambdaS3Function.java:14)",
    "org.springframework.cloud.function.core.FluxFunction.lambda$apply$0(FluxFunction.java:47)",
    "reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:107)",
    "reactor.core.publisher.FluxJust$WeakScalarSubscription.request(FluxJust.java:90)",
    "reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:159)",
    "reactor.core.publisher.BlockingIterable$SubscriberIterator.onSubscribe(BlockingIterable.java:214)",
    "reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:90)",
    "reactor.core.publisher.FluxJust.subscribe(FluxJust.java:67)",
    "reactor.core.publisher.FluxMapFuseable.subscribe(FluxMapFuseable.java:63)",
    "reactor.core.publisher.BlockingIterable.iterator(BlockingIterable.java:80)",
    "org.springframework.cloud.function.adapter.aws.SpringBootRequestHandler.result(SpringBootRequestHandler.java:54)",
    "org.springframework.cloud.function.adapter.aws.SpringBootRequestHandler.handleRequest(SpringBootRequestHandler.java:49)",
    "sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)",
    "sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)",
    "sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)",
    "java.lang.reflect.Method.invoke(Method.java:498)"
  ]
}

函数处理程序:com.mj.aws.lambda.s3.AwsLambdaS3FunctionHandler :: handleRequest

0 个答案:

没有答案