我有一个内置到 GraalVM 本机映像的 Micronaut 应用程序。当我从正常的角度(即没有 Graal)运行应用程序时,它运行完美。
但是,当我尝试从 Graal 运行时,在尝试将字符串反序列化为枚举时出现以下运行时异常:
org.apache.kafka.common.errors.SerializationException: Error deserializing key/value for partition queue.mes.tm_email_processing_result-0 at offset 57. If needed, please seek past the record to continue consumption.
Caused by: io.micronaut.core.serialize.exceptions.SerializationException: Error deserializing object from JSON: Class fts.marketing.utils.deserializers.CampaignEmailStatusDeserializer has no default (no arg) constructor
at [Source: (byte[])"{"merchant":"Lab6","customerId":729441,"campaignRunId":51,"status":"Sent","messageKey":"70bb5454-8e22-4b37-bba7-83c0dd0cb66f"}"; line: 1, column: 1]
at io.micronaut.jackson.serialize.JacksonObjectSerializer.deserialize(JacksonObjectSerializer.java:70)
at io.micronaut.configuration.kafka.serde.JsonSerde.deserialize(JsonSerde.java:79)
at org.apache.kafka.common.serialization.Deserializer.deserialize(Deserializer.java:60)
at org.apache.kafka.clients.consumer.internals.Fetcher.parseRecord(Fetcher.java:1264)
at org.apache.kafka.clients.consumer.internals.Fetcher.access$3600(Fetcher.java:124)
at org.apache.kafka.clients.consumer.internals.Fetcher$PartitionRecords.fetchRecords(Fetcher.java:1488)
at org.apache.kafka.clients.consumer.internals.Fetcher$PartitionRecords.access$1600(Fetcher.java:1328)
at org.apache.kafka.clients.consumer.internals.Fetcher.fetchRecords(Fetcher.java:641)
at org.apache.kafka.clients.consumer.internals.Fetcher.fetchedRecords(Fetcher.java:602)
at org.apache.kafka.clients.consumer.KafkaConsumer.pollForFetches(KafkaConsumer.java:1294)
at org.apache.kafka.clients.consumer.KafkaConsumer.poll(KafkaConsumer.java:1225)
at org.apache.kafka.clients.consumer.KafkaConsumer.poll(KafkaConsumer.java:1201)
at io.micronaut.configuration.kafka.processor.KafkaConsumerProcessor.lambda$process$7(KafkaConsumerProcessor.java:393)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:460)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
作为参考,我的解串器如下:
public class CampaignEmailStatusDeserializer extends JsonDeserializer<CampaignEmailStatus> {
@Override
public CampaignEmailStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
String readValue = p.getText();
if (readValue == null) {
return CampaignEmailStatus.UNKNOWN;
}
return Arrays.stream(CampaignEmailStatus.values())
.filter(status -> status.getDisplayName().equals(readValue))
.findAny()
.orElse(CampaignEmailStatus.UNKNOWN);
}
}
我认为我可能需要为 Graal 添加一些自定义反射配置,但我不太确定。任何人都可以在这里阐明一下吗?