Ошибка десериализации сообщений Avro в AWS Lambda Handler JavaJAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Ошибка десериализации сообщений Avro в AWS Lambda Handler Java

Сообщение Anonymous »

У меня возникла проблема при попытке получить события Kafka из коннектора Lambda.
Он сообщает о следующей ошибке:

Код: Выделить всё

Error loading class com.aleatory.StormEvents.Handler: org/apache/avro/io/Decoder: java.lang.NoClassDefFoundError
java.lang.NoClassDefFoundError: org/apache/avro/io/Decoder
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.avro.io.Decoder
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)
Мой класс Lambda Handler:

Код: Выделить всё

public class LambdaHandler implements RequestHandler {

@Override
public String handleRequest(KafkaEvent event, Context context) {
log.info("Event input: {}", event);
event.getRecords().entrySet().stream()
.flatMap(recordData -> recordData.getValue().stream())
.forEach(kafkaEventRecord -> {
try {
String avroData = new String(Base64.getDecoder().decode(kafkaEventRecord.getValue()));
EventComandControl avro = deserializeAvro(avroData);
ManageControl domainObject = convertToDomainObject(avro);
useCase.process(domainObject);
} catch (IOException e) {
log.error("Error to process message Avro", e);
}
});
return "Ok!";
}

private EventComandControl deserializeAvro(String avro) throws IOException {
DatumReader reader = new SpecificDatumReader(EventComandControl.class);
JsonDecoder decoder = DecoderFactory.get().jsonDecoder(EventComandControl.getClassSchema(), avro);
return reader.read(null, decoder);
}
Я использую зависимости Avro:

Код: Выделить всё

org.apache.avro
avro
1.11.1


org.apache.avro
avro-tools
1.10.2

Я использую Java 17 со Spring Boot 3xx и AWS Lambda.

Подробнее здесь: https://stackoverflow.com/questions/781 ... ndler-java
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»