【问题标题】:AWS Lambda - Spring boot is not handling the requestAWS Lambda - Spring Boot 未处理请求
【发布时间】:2019-02-28 16:53:17
【问题描述】:

我正在尝试在 AWS lambda 中将 Spring Boot 应用程序作为无服务器运行,并且在调用 lambda 函数时遇到异常。 Spring Boot 应用程序成功运行,但似乎无法映射请求

        2018-09-25 06:11:50.717 INFO 1 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
        2018-09-25 06:11:50.823 INFO 1 --- [ main] **my.service.Application : Started Application in 7.405 seconds (JVM running for 8.939)**
        START RequestId: decfc13c-c089-11e8-bacd-a37f1ba65629 Version: $LATEST
        2018-09-25 06:11:50.994 ERROR 1 --- [ main] **c.a.s.p.i.s.AwsProxyHttpServletRequest : Called set character encoding to UTF-8 on a request without a content type. Character encoding will not be set
        2018-09-25 06:11:51.175 ERROR 1 --- [ main] o.s.boot.web.support.ErrorPageFilter : Forwarding to error page from request [/] due to exception [null]**

        java.lang.NullPointerException: null
        at com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletRequest.getRemoteAddr(AwsProxyHttpServletRequest.java:575) ~[task/:na]
        at org.springframework.web.servlet.FrameworkServlet.publishRequestHandledEvent(FrameworkServlet.java:1075) ~[task/:na]
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) ~[task/:na]

        .........

        2018-09-25 06:11:51.535 ERROR 1 --- [ main] s.p.i.s.AwsLambdaServletContainerHandler : Could not forward request

这是我的 StreamLambdaHandler java 文件。

public class StreamLambdaHandler implements RequestStreamHandler {
    private static SpringBootLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> handler;
    static {
        try {
            handler = SpringBootLambdaContainerHandler.getAwsProxyHandler(Application.class);
        } catch (ContainerInitializationException e) {

            throw new RuntimeException("Could not initialize Spring Boot application", e);
        }
    }

    @Override
    public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context)
            throws IOException {
        handler.proxyStream(inputStream, outputStream, context);
        outputStream.close();
    }
}

【问题讨论】:

  • 有什么更新吗?我遇到了同样的问题

标签: spring-boot aws-lambda aws-api-gateway


【解决方案1】:

看起来您可能正在点击https://github.com/awslabs/aws-serverless-java-container/issues/172。根据票证,该修复程序将作为即将发布的 1.2 版本的一部分提供。

【讨论】:

    猜你喜欢
    • 2018-01-28
    • 2020-06-27
    • 1970-01-01
    • 1970-01-01
    • 2018-02-23
    • 1970-01-01
    • 1970-01-01
    • 2016-01-27
    相关资源
    最近更新 更多