[英]Class not found Exception in AWS Java Lambda
this is the exception we get这是我们得到的例外
Exception:
java.lang.ClassNotFoundException: com.A.B.C.ZZZZZZZZZZZZZZZZZZ
at java.base/java.net.URLClassLoader.findClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Unknown Source)
all the source is in the root directory and the lib in the lib directory所有源代码都在根目录中,lib 在 lib 目录中
this works when built from local machine but not from Jenkins这在从本地机器而不是从 Jenkins 构建时有效
in both jenkins and on local mac we used Gradle to compile, the Gradle zip build the zip artifact在 jenkins 和本地 mac 上,我们使用 Gradle 进行编译,Gradle zip 构建了 zip 工件
to be more specific I followed whats here https://docs.aws.amazon.com/lambda/latest/dg/create-deployment-pkg-zip-java.html更具体地说,我在这里关注的是https://docs.aws.amazon.com/lambda/latest/dg/create-deployment-pkg-zip-java.html
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'jars', include: '*.jar')
}
task buildZip(type: Zip) {
from compileJava
from processResources
into('lib') {
from configurations.runtimeClasspath
}
}
seems which is not enough we also need to use chmod似乎这还不够,我们还需要使用 chmod
The root folder did not have read permission for everyone.根文件夹没有所有人的读取权限。 To fix the problem,i I had to call
chmod
to set the permissions properly before the zip task.为了解决这个问题,我不得不在 zip 任务之前调用
chmod
来正确设置权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.