-
Notifications
You must be signed in to change notification settings - Fork 559
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
NPE: While trying to integrate RESTAPI from Springboot app using API gateway lambda proxy #227
Comments
Based on the exception location, I'm guessing you don't have the multi-value headers enabled. Are you running via API Gateway, ALB, or testing locally? |
i was trying to run it through API gateway. i am able to get a fix for this if i create the stack using Cloudformation template or SAM. But i still dont know what i was missing when i was trying to set it up manually piece by piece in the console. But with CFT stack I am able to use API endpoint without any issues. It's working all good but when I checked the logs I did some error in the logs, in spite of the error I am able to run my application via API gateway. Can you help me with what the potential reason for the error in the logs 2019-01-17 19:13:38.034 INFO 1 --- [ main] com.redis.Lambda.LambdaApplication : Starting LambdaApplication on ip-10-146-246-20.ec2.internal with PID 1 (/var/task started by sbx_user1080 in /) |
Hey @sandeeppilania, if it works fine when you go through SAM this is likely a setup issue in API Gateway. Have you configured the integration settings for the API Gateway method to use a proxy integration? |
i am also getting the same issue and trying to call from apigee. { And errors also same |
@sapessi Thanks for your comments, will wait for your update. |
@sapessi do you have any update on this issue. |
Hey @kart2018, we published version |
@sapessi Really Appreciated to get the new version. I have tried with 1.3.1 and getting the same error and don't see any difference. My Lambda Handler Code is below package com.java.test.lambda.demo; import java.io.IOException; import org.slf4j.Logger; import com.amazonaws.serverless.exceptions.ContainerInitializationException; public class DemoBuildLambdaHandler implements RequestStreamHandler {
@OverRide Do i have to use custom handler for APIGEE ? Will it above code would work with only API Gateway ? Please confirm and need your help again on this issue. Need your inputs also. |
I can guarantee that the above code would work via API Gateway. I cannot test against Apigee so I have no way of knowing. Are you sure the exception is exactly the same? Same line of code? |
Yes, exactly the same error. Why this code is not working with APIGEE ...I am really not sure why is there difference using API Gateway and APIGEE both functionality are same. 2019-03-05 15:05:22.291 INFO 1 --- [ main] c.v.b.l.a.BuildApprovalLambdaHandler : Created AWS Handler, com.amazonaws.serverless.proxy.spring.SpringBootLambdaContainerHandler@e70f13a java.lang.NullPointerException: null 2019-03-05 15:05:22.328 ERROR 1 --- [ main] c.a.s.proxy.AwsProxyExceptionHandler : Called exception handler for: java.lang.NullPointerException: null |
@sapessi 2019-03-05 15:05:22.291 INFO 1 --- [ main] c.v.b.l.a.BuildApprovalLambdaHandler : Created AWS Handler, com.amazonaws.serverless.proxy.spring.SpringBootLambdaContainerHandler@e70f13a java.lang.NullPointerException: null 2019-03-05 15:05:22.328 ERROR 1 --- [ main] c.a.s.proxy.AwsProxyExceptionHandler : Called exception handler for: java.lang.NullPointerException: null |
I'm staring at the NPE line of code and I cannot figure out what null would escape from the checks around it. Any chance you could share a dump of the incoming event so that I can built a unit test around it? The difference must be in the event model. We expect an API Gateway-style proxy event. I do not know what type of event Apigee generates. |
@sapessi The below is the input event we are passing and not sure where to find the type of event Apigee generates. In this case, since i am using APIGee, this would be sending a payload which is much different to API GW proxy or ALB proxy, which would result in null pointer errors. { |
This framework will not be able to support that event out of the box. You'll need to either add support for a custom event type yourself - I've written a wiki guide for it - or transform it yourself to an |
It works for me! |
Scenario
NPE with Spring Boot Example and calling default URL:
curl -X GET https://xxx.execute-api.eu-west-1.amazonaws.com/Prod/greeting
Expected behavior
Hello World
Actual behavior
Error - HTTP Code 500
Steps to reproduce
I am trying stepup a simple helloworld application using api gateway and lambda proxy, i am using
handler.proxyStream exactly simliar to the samples. And i have stood up a API gateway with Lamdba function proxy manually through console and i am trying to test through the console Api gateway Test itself. I am not sure what i am missing majorly over here. I did try with handle.proxy option as well but no success. Can you please advice me where i am missing on this. Looking for help
Full log output
START RequestId: 4bfef8c4-d015-4500-ad68-e85130c1f173 Version: $LATEST
2019-01-15 19:58:24.522 INFO 1 --- [ main] c.e.LambdaHandler.StreamLambdaHandler : HI there
2019-01-15 19:58:24.556 ERROR 1 --- [ main] c.a.s.p.internal.LambdaContainerHandler : Error while handling request
java.lang.NullPointerException: null
at com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletRequestReader.readRequest(AwsProxyHttpServletRequestReader.java:39) ~[task/:na]
at com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletRequestReader.readRequest(AwsProxyHttpServletRequestReader.java:29) ~[task/:na]
at com.amazonaws.serverless.proxy.internal.LambdaContainerHandler.proxy(LambdaContainerHandler.java:174) ~[task/:na]
at com.example.LambdaHandler.StreamLambdaHandler.handleRequest(StreamLambdaHandler.java:51) [task/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at lambdainternal.EventHandlerLoader$PojoMethodRequestHandler.handleRequest(EventHandlerLoader.java:259) [LambdaSandboxJava-1.0.jar:na]
at lambdainternal.EventHandlerLoader$PojoHandlerAsStreamHandler.handleRequest(EventHandlerLoader.java:178) [LambdaSandboxJava-1.0.jar:na]
at lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:888) [LambdaSandboxJava-1.0.jar:na]
at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:293) [LambdaSandboxJava-1.0.jar:na]
at lambdainternal.AWSLambda.(AWSLambda.java:64) [LambdaSandboxJava-1.0.jar:na]
at java.lang.Class.forName0(Native Method) [na:1.8.0_181]
at java.lang.Class.forName(Class.java:348) [na:1.8.0_181]
at lambdainternal.LambdaRTEntry.main(LambdaRTEntry.java:104) [LambdaJavaRTEntry-1.0.jar:na]
2019-01-15 19:58:24.557 ERROR 1 --- [ main] c.a.s.proxy.AwsProxyExceptionHandler : Called exception handler for:
java.lang.NullPointerException: null
The text was updated successfully, but these errors were encountered: