Comments (13)
Thanks @lskrajny - marking as a bug for now. I'll investigate and let you know next week.
from aws-serverless-java-container.
I could replicate this in travis CI but not in local. I suspect this is a race condition where the ignite
method is not called consistently before the handle method is called. To get around this, I have moved the Spark filter initialization to the constructor too.
This seems to work in the travis CI build, the only place where I could replicate the issue - still not clear whether this is an issue with Spark 2.6.0 or something that is expected.
@lskrajny can you help me test by checking out 0.8-SNAPSHOT
from the servlet-improvements
branch?
from aws-serverless-java-container.
tested it but unfortunately this doesn't still seem to work:
START RequestId: f9662496-bd7a-11e7-88c9-d3bd55287df8 Version: $LATEST
30 Oct 2017 14:02:34 INFO LambdaContainerHandler - Starting Lambda Container Handler
30 Oct 2017 14:02:35 INFO LambdaHandler - Registering path: /v1
30 Oct 2017 14:02:35 ERROR LambdaContainerHandler - Error while handling request
java.lang.NullPointerException
at com.amazonaws.serverless.proxy.spark.SparkLambdaContainerHandler.handleRequest(SparkLambdaContainerHandler.java:171)
at com.amazonaws.serverless.proxy.spark.SparkLambdaContainerHandler.handleRequest(SparkLambdaContainerHandler.java:65)
at com.amazonaws.serverless.proxy.internal.LambdaContainerHandler.proxy(LambdaContainerHandler.java:126)
at com.logindex.lambda.LambdaHandler.handleRequest(LambdaHandler.kt:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at lambdainternal.EventHandlerLoader$PojoMethodRequestHandler.handleRequest(EventHandlerLoader.java:259)
at lambdainternal.EventHandlerLoader$PojoHandlerAsStreamHandler.handleRequest(EventHandlerLoader.java:178)
at lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:888)
at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:281)
at lambdainternal.AWSLambda.<clinit>(AWSLambda.java:64)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at lambdainternal.LambdaRTEntry.main(LambdaRTEntry.java:94)
30 Oct 2017 14:02:35 ERROR AwsProxyExceptionHandler - Called exception handler for:
java.lang.NullPointerException
at com.amazonaws.serverless.proxy.spark.SparkLambdaContainerHandler.handleRequest(SparkLambdaContainerHandler.java:171)
at com.amazonaws.serverless.proxy.spark.SparkLambdaContainerHandler.handleRequest(SparkLambdaContainerHandler.java:65)
at com.amazonaws.serverless.proxy.internal.LambdaContainerHandler.proxy(LambdaContainerHandler.java:126)
at com.logindex.lambda.LambdaHandler.handleRequest(LambdaHandler.kt:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at lambdainternal.EventHandlerLoader$PojoMethodRequestHandler.handleRequest(EventHandlerLoader.java:259)
at lambdainternal.EventHandlerLoader$PojoHandlerAsStreamHandler.handleRequest(EventHandlerLoader.java:178)
at lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:888)
at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:281)
at lambdainternal.AWSLambda.<clinit>(AWSLambda.java:64)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at lambdainternal.LambdaRTEntry.main(LambdaRTEntry.java:94)
30 Oct 2017 14:02:35 INFO LambdaEmbeddedServer - Spark called configureWebSockets. However, web sockets are not supported
30 Oct 2017 14:02:35 INFO LambdaEmbeddedServer - Starting Spark server, ignoring port and host
30 Oct 2017 14:02:35 INFO LambdaEmbeddedServer - Called join method, nothing to do here since Lambda only runs a single event per container
END RequestId: f9662496-bd7a-11e7-88c9-d3bd55287df8
REPORT RequestId: f9662496-bd7a-11e7-88c9-d3bd55287df8 Duration: 875.76 ms Billed Duration: 900 ms Memory Size: 512 MB Max Memory Used: 57 MB
from aws-serverless-java-container.
Thanks for testing @lskrajny - I'll try and do some more work to replicate it. I would expect it to happen with the unit tests that start applications but so far I haven't had any luck.
from aws-serverless-java-container.
Hey @lskrajny - I'm still struggling to replicate in local. However, Travis CI did fail the build with a similar issues, really seems to be a race condition. I have made a couple of small changes and since then the Travis build has worked correctly. Do you mind testing again version 0.8-SNAPSHOT
from the servlet-improvements
branch?
from aws-serverless-java-container.
Hi @sapessi - tested recent build, and observed NPE now is indeed less frequent, but it still exists. So possibility of the race was reduced but not eliminated.
In the meantime found solution to the initial problem, after adding Spark.awaitInitialization()
in the initialization code of the Lambda handler (not the container library) NPE on initialization went away.
So initialization code looks like this (based on PetStore example):
handler = SparkLambdaContainerHandler.getAwsProxyHandler()
defineResources()
Spark.awaitInitialization()
So the solution is either to modify the spark example to block until spark is initialized or trying to incorporate the fix in the library.
Hope that helps
from aws-serverless-java-container.
Thanks @lskrajny - I was basing my implementation on the default Jetty embedded server and it doesn't look like they call that method. Regardless, sounds like the right thing to do. I will incorporate the call in the framework and commit the changes now. Thanks for putting so much time into this. I'll push out 0.8 ASAP
from aws-serverless-java-container.
Cool, once done will test
from aws-serverless-java-container.
Change is committed to the servlet-improvements branch. All unit tests still pass.
from aws-serverless-java-container.
Strange, it is still throwing NPE :/
Could it be it is executing Spark.awaitInitialization()
before routes are defined?
Regression tested using Spark.awaitInitialization()
outside of the library and it works
from aws-serverless-java-container.
Looks like you are right. may have to call the awaitInitialization() after the routes are included. I'll add it to the documentation and sample instead :(
from aws-serverless-java-container.
ok. Pushed the updates to the servlet-improvements
branch. I simply updated the README
to include the call to awaitInitialization()
and also added it to the sample app. Testing the changes now and then I'll commit and merge.
from aws-serverless-java-container.
@lskrajny I'm closing this issue for now. If you run into the error again even with the awaitInitialization re-open it and I'll dig deeper.
from aws-serverless-java-container.
Related Issues (20)
- Reinitialization of Spring context when using SnapStart HOT 3
- Spring Cloud Gateway throwing "hostname can't be null" based on my request only having headers and not multi-value headers HOT 4
- ServletContext: Servlet.getServletConfig() is null HOT 1
- Cannot invoke "org.springframework.web.servlet.DispatcherServlet.getServletContext()" because "servlet" is null HOT 4
- org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: No content to map due to end-of-input HOT 1
- org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: No content to map due to end-of-input HOT 8
- Cannot deserialize value of type `java.lang.String` from Object value HOT 3
- SpringDelegatingLambdaContainerHandler unable to respond with rendered templates HOT 10
- SpringDelegatingLambdaContainerHandler does not handle Headers correctly for FunctionUrls HOT 7
- Cookies not able to be deleted by setting max-age to 0 HOT 3
- com.amazonaws.serverless.exceptions.InvalidRequestEventException: The incoming event is not a valid request from Amazon API Gateway or an Application Load Balancer HOT 2
- 2.x release HOT 1
- AwsProxyResponse class is generating response JSON which is rejected by API gateway with Malformed error HOT 3
- Moved AwsProxyRequestBuilder into test package HOT 4
- How to handle spring security with springboot serverless HOT 2
- Null Pointer While Setting Filter Post Startup Lambda Handler HOT 2
- Spring boot 3 context initialization issue when using with a servlet application having webflux dependency for web client HOT 3
- Error with version 2.0.2 when multi-value header is active in alb HOT 6
- Springboot 2 Lambda Layer Support HOT 2
- Query parameter values not URL decoded when using HTTP API V2 Gateway with a RequestStreamHandler implementation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-serverless-java-container.