-
Notifications
You must be signed in to change notification settings - Fork 11
Can't get CoreUtilites Example running (JDK 11) #67
Comments
Hi @rieckpil Thanks for opening the issue. The utility for sure works well with java 11 and further too. Infact we have that validated as part of the build process of utility too, before we make a release. That being said, I just tried the example as is and using aws sam template provided in the example and everything worked fine as it should have. I also tried the serverless framework example you had, there off course it failed, like you mentioned above. I tried changing the function code to
instead of
and then it works fine. So there has to be some difference for sure between how sam is packaging thing vs just deploying the jar directly. I will recommend explicitly specifying the class when initializing logger until i see why log4j is not able to figure things out on its own when running as plain jar vs what SAM packages and builds |
After digging a bit more, the real reason here is and this post was really helpful as well.
But because AWS Lambda extracts the jar, the META-INF directory is not "seen" by the JVM anymore, and anything that was in META-INF/versions is ignored. So basically, this is not just specific to powertools but basically, log4j2 and java lambda function configuration. That being said, what we are going to do in powertools specifically:
I will copy this issue to powertools repo itself. |
Here is the issue aws-powertools/powertools-lambda-java#825 |
Wow, thanks for the quick help @pankajagrawal16. Oh yikes, I was digging so deep into this :D Thanks for your investigation effort 🥳 I'll also take a closer look into favoring the assembly plugin over the shade plugin. PS: I can confirm that with the suggested change it works 👍 |
Hey 👋🏻
I'm trying to enrich my existing AWS Lambda Java setup with the structured logging functionality. However, I'm failing to get it running with Java 11.
To confirm that it's not something project-specific I forked this sample project and tried to run the
helloworld.App
on a Java 11 default AWS Lambda runtime and get the following error:Some basic research pointed me to this issue https://issues.apache.org/jira/browse/LOG4J2-2834 that mentions a fix by adding
Multi-Release:true
to theManifest.md
.I tried to add this by enriching the transformer setup but still get the same issue when running the sample Lambda of this repo.
What's weird is that this issue seems to only occur on the AWS Lambda runtime. If I manually add the Lambda handler as the
Main-Class
with a basicmain
method that invokes the function, and runjava -jar target/...
I don't see this exception locally.Reproducible example: https://github.com/rieckpil/aws-lambda-powertools-examples
With a
java8.al2
runtime it works fine, but I'd like to avoid downgrading all my lambdas to Java 8 in 2022 😅Any ideas?
The text was updated successfully, but these errors were encountered: