Reputation: 369
We are developing a project to process files using lambda functions triggered by an API Gateway request. The function then gets the file in a S3 bucket and starts reading it. Until this points, everything works like expected, but when the file reading starts we receive 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 custom file reading/process library (a Java project) due to the fact the file is also customized to our needs, we added it to our project using Maven. Our lambda jar 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>
Testing the project locally, it works fine and we can get the file information. Our code uses JAX-RS and Spring to deal with the API Gateway (we aren't sure if this could interfere in the results). But, until now we weren't able to solve this problem when running the project using lambda. During our tests we increased the function timeout and memory on purpose, but no matter what the limits are, the error persists.
Thank you in advance.
Upvotes: 4
Views: 1081
Reputation: 369
Using log techniques, debuging our code and contacting AWS support we saw that one of our libraries was creating files inside a forbidden directory, as explained here: https://aws.amazon.com/lambda/faqs/ , and so the Lambda function was failing.
They explained that if you need to create files, you must use the /tmp directory, we didn't notice this until we had this problem. We read the documentation over and over, but this one thing still caught us, it happens, I think. Anyway, after changing this in the library the function now executes perfectly as expected.
Thank you all for the help.
Upvotes: 1
Reputation: 94
Are you still having the problem? It could be that Lambda service is being maintained in that particular region you are using. This error tells me that the JRE is corrupted and libraries provided by rt.jar cannot be accessed. Contact the support if necessary. You can check the AWS healths here.
Upvotes: 0