Changing Event Location

I created some events then noticed that they were in the wrong folder. When I displaced them to the right folder, I got an UnknownSerializedTypeException. XStream doesn’t recognize the events any longer.

I tried writing an upcaster, which is not seen at run time. I don’t know if this is correct:


private static SimpleSerializedType targetType = new SimpleSerializedType(
        "event.old.path", "1.0");

protected boolean canUpcast(IntermediateEventRepresentation intermediateRepresentation) {
    return intermediateRepresentation.getType().equals(targetType);

protected IntermediateEventRepresentation doUpcast(IntermediateEventRepresentation intermediateRepresentation) {
    return intermediateRepresentation.upcastPayload(
            new SimpleSerializedType(
                    "", "2.0"),


Is this the correct way of writing upcasters and is there another way to deal with this without using upcasters?

Hi Harvey,

Adjusting the fully qualified class name of an event is a reason to write an upcaster, so making one was the right approach.
I would say to only write upcasters for events which are used in production though.
As long as you’re not in production, the events are probably not ‘mission critical’, so you can drop them altogether.

Code wise you’re making one mistake there.
You only want to adjust the SimpleSerializedType, but you’re also putting null for the upcast function, which will drop the payload if I’m correct.
It’s better to do Function.identity(), thus letting it return the payload as is.

To wire an upcaster you need to put it in an EventUpcasterChain bean.
That should automatically get picked up by the EventStorageEngine if you’re in a Axon Spring Boot environment.

Hope this helps you out.



If you use the XStreamSerializer, there is one alternative: aliases. Using Aliases is recommended to map full package names to mere prefixes. For example, set an alias for “” to “core”. The serialized for will contain “core”. If you move classes, you can then change the alias to another package.

These aliases can also be (ab)used to register moved packages. When you have moved a class from package a to package b, you can map the a package to b as follows:
1- Register “a” as an alias to package “b”
2- Register “b” as an alias to package"b".

That last step is necessary to force XStream to serialize the new package to the same name. Alternatively, you can register a proper alias to package b.

To register aliases, use the “addPackageAlias” method on the XStreamSerializer.



PS. If you’re not in production, don’t do this. Follow Steven’s advice and start with a clean slate instead.