You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use aws-lambda-java-tests, but I am unable to deserialize objects to pass to the test cases. I receive java.lang.ClassNotFoundException: com.amazonaws.services.s3.event.S3EventNotification$S3EventNotificationRecord.
I am having a simple lambda with two entry points, where one is just an entry to run test cases on the other one. However, I am encountering the above issue when I am trying to create an s3Event from EventLoader.loadS3Event
Please let me know if there is a way in which I can fix this problem, or if there exist any workarounds to it. Thanks
I am using aws lambda invoke --function-name aws-helloworld-junt5-test --payload file://AWSTestingHelloWorld/src/test/resources/events/put.json response2.txt
Here is my Lambda code
I have edited the issue to a minimal reproducible code. I am no longer blocked on it as I found other ways to get to what I want.
The code above contains (1) a lambda function, and (2) test class for the lambda.
The lambda function has an entrypoint with the signature public String handleRequest(Object s3Event, Context context) which loads the testing class of the lambda using junit 5, such that the single testing method reinvokes the lambda but on a different entrypoint public String handleRequest(S3Event s3Event, Context context) .
To be able to do that, there are multiple classloaders used. There is the one that is used in launcher.execute(request);, then there is also another one that is happening in S3Event s3Event = EventLoader.loadS3Event("events/put.json");. That later line is where the problem lies as it crashes with the following exception:
My guess is that what is going on has to do with different classloaders working, but in isolation due to some java security, thus when we are loading the S3EventNotificationRecord it is not within the visibility of the running classloader. I'm not an expert on the matter, but according to issue #262, using Thread.currentThread().getContextClassLoader() instead of the below classloaders (also found in here), can potentially solve the problem. Though I am not sure if that fix really works, and I am not sure if such a change could have other side effects.
I am trying to use
aws-lambda-java-tests
, but I am unable to deserialize objects to pass to the test cases. I receivejava.lang.ClassNotFoundException: com.amazonaws.services.s3.event.S3EventNotification$S3EventNotificationRecord
.This might be related to issue ##262
I am having a simple lambda with two entry points, where one is just an entry to run test cases on the other one. However, I am encountering the above issue when I am trying to create an
s3Event
fromEventLoader.loadS3Event
Please let me know if there is a way in which I can fix this problem, or if there exist any workarounds to it. Thanks
I am using
aws lambda invoke --function-name aws-helloworld-junt5-test --payload file://AWSTestingHelloWorld/src/test/resources/events/put.json response2.txt
Here is my Lambda code
And here is my lambda test code
The text was updated successfully, but these errors were encountered: