0

This is my first time deploying to AWS Lambda and am getting a little stuck.

I have a large maven project called Helpers which has many submodules, many of them dependent on each other. In there I have one Helper called Alerts. I have a parent directory and everything builds and compiles successfully. So, that's good.

In Alerts there's a class called PaymentAlerts which has the line

import com.mywebsite.messages.Doers

where messages.Doers is found in the dependencies.

But, when I do a mvn package on the whole project and I find alerts-1.0.jar and upload it to AWS Lambda and I set my handler as com.mywebsite.alerts.PaymentAlerts::doAlert I get the following error:

{

com.mywebsite.alerts.PaymentAlerts: com/mywebsite/messaging/Doers",

"errorType": "java.lang.NoClassDefFoundError"

"errorMessage": "Error loading class }

How do I reconfigure this so that it finds all the necessary files?

Any and all help is appreciated!

LivingRobot
  • 883
  • 2
  • 18
  • 34

2 Answers2

0

AWS Lambda can't find dependent library

Except mvn, you can do with simple library dependency by putting all jars in one, Where your MANIFEST file contains like Class-Path: libs/xyz.jar libs/abc.jar ...

Hope this process can resolve your "errorType": "java.lang.NoClassDefFoundError"

  • It turns out that instead of manually doing this if you use the `maven-shade-plugin` everything gets done for you and you don't have to worry about it. At least, it worked for me. Thanks! – LivingRobot Oct 09 '17 at 20:42
  • It didn't work. But, then after looking at your answer and poking around I was able to find the answer. Sorry for any problems. – LivingRobot Oct 09 '17 at 20:47
0

From here I was able to find out about maven-shade-plugin which jarred everything together nicely and solved the problem.

LivingRobot
  • 883
  • 2
  • 18
  • 34