在Java中使用AWS Lambda打印“ Hello World”时观察到JsonMappingException

时间:2019-11-05 10:23:54

标签: java aws-lambda

以下程序是要与AWS lambda一起执行的POC。我想在控制台上打印Hello World。

package com.example.main;
public class HelloWorld {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    System.out.println("***********Hello World**********");
 }
}

我创建了一个可运行的jar并尝试使用AWS lambda执行,但是观察到以下异常:

    {
  "errorMessage": "An error occurred during JSON parsing",
  "errorType": "java.lang.RuntimeException",
  "stackTrace": [],
  "cause": {
    "errorMessage": "com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token\n at [Source: lambdainternal.util.NativeMemoryAsInputStream@1e88b3c; line: 1, column: 1]",
    "errorType": "java.io.UncheckedIOException",
    "stackTrace": [],
    "cause": {
      "errorMessage": "Can not deserialize instance of java.lang.String out of START_OBJECT token\n at [Source: lambdainternal.util.NativeMemoryAsInputStream@1e88b3c; line: 1, column: 1]",
      "errorType": "com.fasterxml.jackson.databind.JsonMappingException",
      "stackTrace": [
        "com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148)",
        "com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:857)",
        "com.fasterxml.jackson.databind.deser.std.StdDeserializer._parseString(StdDeserializer.java:846)",
        "com.fasterxml.jackson.databind.deser.std.StringArrayDeserializer.handleNonArray(StringArrayDeserializer.java:147)",
        "com.fasterxml.jackson.databind.deser.std.StringArrayDeserializer.deserialize(StringArrayDeserializer.java:47)",
        "com.fasterxml.jackson.databind.deser.std.StringArrayDeserializer.deserialize(StringArrayDeserializer.java:17)",
        "com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1511)",
        "com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1102)"
      ]
    }
  }
}

0 个答案:

没有答案