Java classpath and multiple jars

HI

Possibly doing something wrong here but I have a few queries… using aws java maven project and having a few issues

  1. I would assume that once a Lambda is built I should use serverless package to create the bundle off of which invoke-bridge works ? If I run serverless invoke local my function is called but the classpath is limited to the directory of invoke-bridge.jar and I can’t see how to add other jar files by way of classpath setting on CLI option ?

2 If it is picking up my handler from the maven’ed jar file I don’t understand why it isn’t picking up another class inside it (in this case mysql driver)

should invoke local run off the serverless packaged archive and be able to find everything without classpath modification or am I doing something wrong ?

thanks

I am seeing the same issue. According to Amazon docs in https://docs.aws.amazon.com/lambda/latest/dg/create-deployment-pkg-zip-java.html, library dependencies should be placed as jars in a lib subdirectory in the zip file. The zip I produce is working on AWS, but with invoke local, the jar files within the .zip are not added to the classpath.

I have had some luck using a shadowJar, which “explodes” all of the jars before sipping everything up" . See https://imperceptiblethoughts.com/shadow/ Maven also has a similar concept.