xStream ForbiddenClassException followed by Axon Connector Converter error

Now that I have 3 microservices [ Product Service ] → [ CORE ] ← [ Order Service ]
Two services has he [ CORE ] as a dependency

I tried to dispatch a command from the the [ Core ] package but I’m getting ForbiddenClassException from commandGateway.send(Command)

com.package.app.order-service

@Saga
public class OrderSaga {
    @Inject
    private transient CommandGateway commandGateway;

    @StartSaga
    @SagaEventHandler(associationProperty = "orderID")
    public void handle(OrderCreatedEvent orderCreatedEvent) {

        commandGateway.send(new ReserveProductCommand(...), (commandMessage, commandResultMessage) -> {
            if (commandResultMessage.isExceptional()) {
                //Start compensating transaction
                LOGGER.error("- SAGA COMMAND ERROR "+commandResultMessage.getPayload());
            }
        });
    }

This is the one I’m not picking
com.package.app.product-service.CreateProductAggregate

@CommandHandler
public void handler(ReserveProductCommand reserveProductCommand) {
    LOGGER.info("+ ProductCommandHandler "
            + this.productID + " " + this.quantity + " " + reserveProductCommand);
    
    AggregateLifecycle.apply(new ProductReservedEvent(...));
}
@Configuration
public class ConverterConfig {
    @Bean
    @ConditionalOnBean(Converter.class)
    @Autowired
    public Collection<Converter> converters(XStream xstream, Collection<Converter> converters) {
        converters.forEach(converter -> xstream.registerConverter((com.thoughtworks.xstream.converters.Converter) converter));
        return converters;
    }
}
@Configuration
public class Config {
    @Bean
    @ConditionalOnMissingBean(XStream.class)
    public XStream xStream() {
        XStream xStream_ = new XStream();
        xStream_.addPermission(PrimitiveTypePermission.PRIMITIVES);
        xStream_.allowTypesByWildcard(new String[]{
                "org.axonframework.**",
                "com.mypackage.app.core.**",
        });
        return xStream_;
    }
}

I’ve created the configuration for xStream and I’m getting this error

*org.axonframework.axonserver.connector.command.AxonServerRemoteCommandHandlingException: An exception was thrown by the remote message handling component: *

  • at org.axonframework.axonserver.connector.ErrorCode.lambda$static$11(ErrorCode.java:86) ~[axon-server-connector-4.5.9.jar:4.5.9]*
  • at org.axonframework.axonserver.connector.ErrorCode.convert(ErrorCode.java:182) ~[axon-server-connector-4.5.9.jar:4.5.9]*
  • at org.axonframework.axonserver.connector.command.CommandSerializer.deserialize(CommandSerializer.java:164) ~[axon-server-connector-4.5.9.jar:4.5.9]*
  • at org.axonframework.axonserver.connector.command.AxonServerCommandBus.lambda$doDispatch$2(AxonServerCommandBus.java:167) ~[axon-server-connector-4.5.9.jar:4.5.9]*
  • at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642) ~[na:na]*
  • at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506) ~[na:na]*
  • at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2073) ~[na:na]*
  • at io.axoniq.axonserver.connector.command.impl.CommandChannelImpl$CommandResponseHandler.onNext(CommandChannelImpl.java:372) ~[axonserver-connector-java-4.5.4.jar:4.5.4]*
  • at io.axoniq.axonserver.connector.command.impl.CommandChannelImpl$CommandResponseHandler.onNext(CommandChannelImpl.java:359) ~[axonserver-connector-java-4.5.4.jar:4.5.4]*
  • at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onMessage(ClientCalls.java:466) ~[grpc-stub-1.43.0.jar:1.43.0]*
  • at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInternal(ClientCallImpl.java:661) ~[grpc-core-1.43.0.jar:1.43.0]*
  • at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:646) ~[grpc-core-1.43.0.jar:1.43.0]*
  • at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) ~[grpc-core-1.43.0.jar:1.43.0]*
  • at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133) ~[grpc-core-1.43.0.jar:1.43.0]*
  • at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]*
  • at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]*
  • at java.base/java.lang.Thread.run(Thread.java:829) ~[na:na]*
1 Like

I don’t understand the @ConditionalOnMissingBean(XStream.class) does it work if you remove it?