GitHub Link
https://github.com/MarcoFaccani/aws-lambda-kotlin-zip-issue
Context
I have an AWS Lambda written in Kotlin and Maven using the AWS Java SDK V2 and Powertools by AWS for serialization. The lambda is invoked from the AWS API Gateway. I am packing the Lambda in a ZIP file using the methodology recommended by O'Reilly book Programming with AWS Lambda, which is to use the following plugins:
<!-- Shade -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven.shade.plugin.version}</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<!-- Suppress module-info.class warning-->
<exclude>module-info.class</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Recommended approach by O'Reilly Programming AWS Lambda book -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/assembly/lambda-zip.xml</descriptor>
</descriptors>
<finalName>lambda</finalName>
</configuration>
</plugin>
<!-- Recommended approach by O'Reilly Programming AWS Lambda book -->
<plugin>
<groupId>io.github.zlika</groupId>
<artifactId>reproducible-build-maven-plugin</artifactId>
<version>0.10</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>strip-jar</goal>
</goals>
</execution>
</executions>
</plugin>
The assembly file is as follows:
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0
http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>lambda-zip</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<includes>
<include>${project.groupId}:${project.artifactId}</include>
</includes>
<unpack>true</unpack>
<unpackOptions>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>META-INF/maven/**</exclude>
</excludes>
</unpackOptions>
</dependencySet>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<unpack>false</unpack>
<scope>runtime</scope>
<outputDirectory>lib</outputDirectory>
</dependencySet>
</dependencySets>
</assembly>
Issue
When I run the Lambda, I get:
java.lang.NoSuchMethodError: 'com.fasterxml.jackson.core.JsonParser com.fasterxml.jackson.databind.ObjectMapper.createParser(java.lang.String)'
ZIP File Content
In the book, it exaplins that the zip file shall contain a /lib folder and within it all the JAR files of the dependencies used in the project. This is true but I also see the packages of each dependency in the root of the zip file (example com/fasterxml/jackson/databind containing all the compiled .class files) and I am wondering if this could be an issue or evidence that the packaging process isn't going as supposed.
Thank you in advance!