Axon Framework throws an error when registering with the Axon Server: ForbiddenClassException

Estoy utilizando

Java 19 Spring Boot: 2.7.5 Axon Framework: 4.6.2 Axon Server: 4.6.7

Al momento de enviar un post para registrar un usuario; veo que ingresa hasta la capa de servicio y al intentar publicar el evento en el Axon Server (Event Store) con el comando: “commandGateway.sendAndWait”(objeto) salta inmediantamente el siguiente error:

Clase de la capa de servicio que publica mediante el comando: commandGateway.sendAndWait en Axon Server

public class UsuarioApplicationService {
private final CommandGateway commandGateway;
private final RegisterUsuarioValidator registerUsuarioValidator;
private final EditUsuarioValidator editUsuarioValidator;

public UsuarioApplicationService(CommandGateway commandGateway, RegisterUsuarioValidator registerUsuarioValidator, EditUsuarioValidator editUsuarioValidator) {
    this.commandGateway = commandGateway;
    this.registerUsuarioValidator = registerUsuarioValidator;
    this.editUsuarioValidator = editUsuarioValidator;

public Result<RegisterUsuarioResponse, Notification> register(RegisterUsuarioRequest request) throws Exception {
    String usuarioId =  UUID.randomUUID().toString();
    String createdBy = UUID.randomUUID().toString();
    RegisterUsuario command = new RegisterUsuario(
    Notification notification = this.registerUsuarioValidator.validate(command);
    if (notification.hasErrors()) return Result.failure(notification);
    commandGateway.sendAndWait(command); //Aquí se cae (esta línea publica el evento en Axon Server)        
    RegisterUsuarioResponse registerUsuarioResponse = new RegisterUsuarioResponse(
    return Result.success(registerUsuarioResponse);

Clase RegisterUsuario


import lombok.Value;
import org.axonframework.modelling.command.TargetAggregateIdentifier;
import java.time.LocalDateTime;

public class RegisterUsuario {
private String id;
private String nombre;
private String clave; 
private String createdBy;

Luego de pasar la línea que contiene el comando mencionado; salta el siguiente error:

Exception in thread “CommandProcessor-0”

Hi @Luis_Humberto_Llatas and welcome to the forum!

My Spanish is virtually non-existent, but I do think I get the gist of your issues based on the exception you’re receiving from XStream.

XStream’s approach to serialization is mainly based on reflection. Something that since JDK16 is being blocked off more and more. Henceforth, Axon Framework’s default Serializer, the XStreamSerializer, becomes less feasible to more recent your JDK version is.

It’s not to say there’s no configuration to make it work, but it likely doesn’t outway the effort right now.

As such, I’d like to recommend you to set Axon’s Serializer to the JacksonSerializer.
You can do this by exposing a bean as follows:

public Serializer serializer(ObjectMapper objectMapper) {
    return JacksonSerializer.builder()

Doing so should set Axon’s default Serializer to a JacksonSerializer instance.
In doing so, you’d remove the default XStreamSerializer you’re currently finding issues with.

By the way, you can find more on Axon’s serializer configuration here.