NoClassDefFoundError when starting AWMS lambda function with libraries

We are developing a project for processing files using lambda functions caused by an API gateway request. The function then receives the file in the S3 bucket and begins to read it. Up to this point, everything works as expected, but when the file starts reading, we get the following error:

(...)
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.101-3.b13.24.amzn1.x86_64/jre/lib/rt.jar: error reading zip file
2017-02-06 19:15:06 <9025af71-eca0-11e6-82d2-9ff4b9184005> ERROR JRestlessHandlerContainer:339 - container failure
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.101-3.b13.24.amzn1.x86_64/jre/lib/rt.jar: error reading zip file
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.101-3.b13.24.amzn1.x86_64/jre/lib/rt.jar: error reading zip file
END RequestId: (some id)
REPORT RequestId: (some id)  Duration: 3047.44 ms    Billed Duration: 3100 ms        Memory Size: 1536 MB    Max Memory Used: 94 MB  

Exception in thread "main" java.lang.Error: java.lang.NoClassDefFoundError: java/lang/Throwable$WrappedPrintWriter
    at lambdainternal.AWSLambda.<clinit>(AWSLambda.java:59)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at lambdainternal.LambdaRTEntry.main(LambdaRTEntry.java:94)
Caused by: java.lang.NoClassDefFoundError:     java/lang/Throwable$WrappedPrintWriter
    at java.lang.Throwable.printStackTrace(Throwable.java:721)
    at lambdainternal.UserFault.trace(UserFault.java:43)
    at lambdainternal.UserFault.makeUserFault(UserFault.java:26)
    at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:290)
    at lambdainternal.AWSLambda.<clinit>(AWSLambda.java:57)
    ... 3 more
START RequestId: (some id) Version: $LATEST
END RequestId: (some id)

We use our own library for reading / processing files (Java project) due to the fact that the file is also configured for our needs, we added it to our project using Maven. Our lambda gang was generated using the Maven Shade plugin:

<plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-shade-plugin</artifactId>
         <version>2.3</version>
         <configuration>
                <createDependencyReducedPom>false</createDependencyReducedPom>
         </configuration>
         <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
  </plugin>

, , . JAX-RS Spring Gateway API ( , ). . - , , , .

.

+4
2

, AWS, , , : https://aws.amazon.com/lambda/faqs/, .

, , /tmp, , . , , , . , , .

.

+1

? , Lambda , . , JRE , , rt.jar, . , . AWS .

0

Source: https://habr.com/ru/post/1670237/


All Articles