大家好,我的lambda上载到在localstack上运行的本地aws lambda时找不到其依赖项。
这就是我创建我的lambda的方式
aws --endpoint-url=http://localhost:4574 lambda create-function --function-name=myFunction --runtime=java8 --role=r1 --handler=my.UpdateHandler --zip-file fileb://my-lambda-0.1.0-1540476215-64df908.zip
这是它的执行方式
aws lambda --endpoint-url=http://localhost:4574 invoke --invocation-type RequestResponse --function-name myFunction --region eu-west-1 --payload {} out.txt
堆栈跟踪如下
Exception: Lambda process returned error status code: 1. Output:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at cloud.localstack.LambdaExecutor.getHandler(LambdaExecutor.java:138)
at cloud.localstack.LambdaExecutor.main(LambdaExecutor.java:52)
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapper
at my.create(Houston.java:56)
at my.UpdateHandler.<init>(UpdateHandler.java:17)
... 6 more
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ObjectMapper
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 8 more
请注意,所讨论的类位于lib目录的jar中,并且也像lambda本身一样位于顶层。
要注意的另一点是,运行没有外部依赖项的helloworld示例可以很好地进行。
任何指针都是有用的。预先感谢