使用java sdk

时间:2018-04-20 03:29:17

标签: java amazon-web-services aws-lambda

尝试使用java sdk以异步模式调用AWS Lambda时,我看到以下错误: -

ERROR [2018-04-20 03:07:09,053] io.dropwizard.jersey.errors.LoggingExceptionMapper: Error handling a request: 4e552086b3525fbf
! java.lang.ClassFormatError: Truncated class file
! at java.lang.ClassLoader.defineClass1(Native Method)
! at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
! at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
! at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
! at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
! at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
! at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
! at java.security.AccessController.doPrivileged(Native Method)
! at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
! 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)
! at com.amazonaws.services.lambda.AWSLambdaClientBuilder.build(AWSLambdaClientBuilder.java:60)
! at com.amazonaws.services.lambda.AWSLambdaClientBuilder.build(AWSLambdaClientBuilder.java:26)
! at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)

我使用过AWS SDK的1.11.106版。我的pom.xml如下所示

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-bom</artifactId>
            <version>1.11.106</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-lambda</artifactId>
</dependency>`

我调用产生此错误的java代码如下

AWSLambda client = AWSLambdaClientBuilder.standard()
                .withCredentials(new DefaultAWSCredentialsProviderChain())
                .withRegion("us-west-2")
                .build();
InvokeRequest request = new InvokeRequest().withFunctionName("streamConsumer").withInvocationType("Event").withLogType("Tail").withClientContext("service").withPayload(ByteBuffer.wrap(json.getBytes("UTF-8"))).withQualifier("1");
InvokeResult response = client.invoke(request);

0 个答案:

没有答案