简体   繁体   中英

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

this works when built from local machine but not from Jenkins

in both jenkins and on local mac we used Gradle to compile, the Gradle zip build the zip artifact

to be more specific I followed whats here 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM