I’m writing my first event upcaster in a Spring Boot 2.3.4 app using Axon framework 4.2.1, but when my upcaster calls upcastPayload()
I get:
org.axonframework.serialization.CannotConvertBetweenTypesException: Cannot build a converter to convert from [B to org.dom4j.Document
at org.axonframework.serialization.ChainedConverter.calculateChain(ChainedConverter.java:59)
The app uses the XStreamSerializer.
My upcaster:
import org.axonframework.serialization.SimpleSerializedType;
import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation;
import org.axonframework.serialization.upcasting.event.SingleEventUpcaster;
import org.dom4j.Document;
[...]
public class MyEventUpcaster extends SingleEventUpcaster {
private SimpleSerializedType oldEventType = new SimpleSerializedType(MyEvent.class.getTypeName(), null);
private SimpleSerializedType newEventType = new SimpleSerializedType(MyEvent.class.getTypeName(), "2");
@Override
protected boolean canUpcast(IntermediateEventRepresentation intermediateEventRepresentation) {
return intermediateEventRepresentation.getType().equals(oldEventType);
}
@Override
protected IntermediateEventRepresentation doUpcast(IntermediateEventRepresentation intermediateEventRepresentation) {
return intermediateEventRepresentation.upcastPayload(newEventType, Document.class, this::upcastEvent);
}
private Document upcastEvent(Document oldEvent) {
// separate for debugging, but never reached
[...]
}
}
I’m under the impression from what I’ve read that there’s built-in conversion for org.dom4j.Document
?