Command resulted in com.thoughtworks.xstream.converters.ConversionException(Failed calling method) when using spring cloud connector for distributed command bus

1,172 views
Skip to first unread message

ashutos...@metamagic.in

unread,
Apr 20, 2018, 10:28:16 AM4/20/18
to Axon Framework Users

I get the below-mentioned exception thrown from saga event handler. I have configured distributed command bus using spring cloud connector, and whenever a command is dispatched from saga event handler using the command gateway this exception id thrown.

Command 'com.metamagic.ms.commands.PlaceOrderCommand' resulted in com.thoughtworks.xstream.converters.ConversionException(Failed calling method
---- Debugging information ----
message             : Failed calling method
cause-exception     : com.thoughtworks.xstream.converters.ConversionException
cause-message       : Failed calling method
method              : java.util.concurrent.CopyOnWriteArrayList.writeObject()
-------------------------------)

My saga event handler code snippet.

        @StartSaga
@SagaEventHandler(associationProperty = "userId")
public void handle(Event event) {

// business logic 
commandGateway
.send(new Command(arguments));
}

Any help will be appreciated.
 

Steven van Beelen

unread,
Apr 24, 2018, 4:57:41 AM4/24/18
to axonfr...@googlegroups.com
Hi Ashutosh,

This 'conversion exception' only occurs when the `PlaceOrderCommand` is published from a Saga?
Thus, you've got a use case were the `PlaceOrderCommand` is published from a non-event-handling-component (I regard a Saga as an Event Handling Component as it's triggered by events) which does work?

And just to be clear, this exception is thrown on the sending side of that command, not on the receiving side, correct?

Could you share a more elaborate stack trace of the exception you're getting?
Maybe that contains some info which I can help you out with, since with the current snippets you've shared I'm kinda at a loss.
My general knowledge of XStream is that it is very good at serializing about everything, so I'm kinda surprised you've got this exception.

Let's try to figure this out; interested what the problem is here!

Cheers,
Steven


Breach of confidentiality

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake then delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.

Liability for the unintentional transmission of computer viruses

WARNING: Although the MetaMagic Global has taken reasonable precautions to ensure no viruses are present in this email, MetaMagic cannot accept responsibility for any loss or damage arising from the use of this email or attachments.

--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ashutos...@metamagic.in

unread,
Apr 25, 2018, 4:17:59 AM4/25/18
to Axon Framework Users
Actually, PlaceOrderCommand is published from non-event-handling component and not from saga event handler. And PlaceOrderCommand results in OrderPlacedEvent from ShoppingCart aggregate. 


My saga code.

        @StartSaga
@SagaEventHandler(associationProperty = "userId")
public void handle(OrderPlacedEvent orderPlacedEvent) {
String orderId = UUID.randomUUID().toString();
associateWith("orderId", orderId);
Set<LineItemDTO> lineItemDTOs = null;
if (orderPlacedEvent.getItems() != null) {
lineItemDTOs = orderPlacedEvent.getItems().stream().map(
items -> new LineItemDTO(items.getItemId(), items.getName(), items.getQuantity(), items.getPrice()))
.collect(Collectors.toSet());
}
commandGateway
.send(new CreateOrderCommand(orderId, orderPlacedEvent.getCartId(), orderPlacedEvent.getUserId(), lineItemDTOs));

Steven van Beelen

unread,
Apr 25, 2018, 4:57:28 AM4/25/18
to axonfr...@googlegroups.com
Hi Ashutosh,

Cant see something wrong in that Saga Event Handler on face value.
If you could still provide a stack trace of the exception your getting, maybe that might shed some light on the issue at hand.

Cheers,
Steven

ashutos...@metamagic.in

unread,
Apr 25, 2018, 5:02:28 AM4/25/18
to Axon Framework Users

o.a.c.gateway.DefaultCommandGateway      : Command 'com.metamagic.ms.commands.PlaceOrderCommand' resulted in com.thoughtworks.xstream.converters.ConversionException(Failed calling method
---- Debugging information ----
message             : Failed calling method
cause-exception     : com.thoughtworks.xstream.converters.ConversionException
cause-message       : Failed calling method
method              : sun.net.www.http.KeepAliveCache.writeObject()
-------------------------------)

I Don't get anything more than this as a warning. 


On Friday, April 20, 2018 at 7:58:16 PM UTC+5:30, ashutos...@metamagic.in wrote:

Steven van Beelen

unread,
Apr 25, 2018, 5:46:59 AM4/25/18
to axonfr...@googlegroups.com
Hi Ashutosh,

Weird, would've expected you'd receive more.
A quick google on the ConversionException you're receiving however does not give any concrete answers to what is going wrong here...

I'd assume though this issue has nothing to do with using the DistributedCommandBus or the Spring Cloud CommandBusConnector/CommandRouter for that matter..
As I suggested in my first response, it might be a good idea to confirm that, by checking if you get the same warning if you publish the PlaceOrderCommand on a CommandBus implementation which does not publish to another node.

I'd however rather say this lies with XStream and how your PlaceOrderCommand is modeled.
What does your PlaceOrderCommand look like, implementation wise?
And one other thing, are your Axon nodes homogeneous or heterogeneous?

Let's figure this out!

Cheers,
Steven

ashutos...@metamagic.in

unread,
Apr 25, 2018, 6:11:55 AM4/25/18
to Axon Framework Users
Thanks Steven.

This problem could not be related to DistributedCommandBus or the Spring Cloud CommandBusConnector/CommandRouter.

I will test the code with SimpleCommandBus and let you know what happened.

And PlaceOrderCommand is an immutable class with two final data members and nothing much. Axon nodes are heterogeneous.


On Friday, April 20, 2018 at 7:58:16 PM UTC+5:30, ashutos...@metamagic.in wrote:

Allard Buijze

unread,
Apr 25, 2018, 6:43:34 AM4/25/18
to axonfr...@googlegroups.com
Hi,

the error shows that XStream is complaining about an HTTP Cache related object. That indicates the class references something that you probably didn’t intend to.
You said the class only references two objects. Is that class perhaps a non-static inner class? Or are you using some (annotation based) enhancers like Lombok? In that case, you might be implicitly referencing other classes as well.

By the way, your first exception showed a different error, where it complained about a concurrent collection. Which fields do you expect your object to contain?

Cheers,

Allard


Breach of confidentiality

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake then delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.

Liability for the unintentional transmission of computer viruses

WARNING: Although the MetaMagic Global has taken reasonable precautions to ensure no viruses are present in this email, MetaMagic cannot accept responsibility for any loss or damage arising from the use of this email or attachments.

--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Allard Buijze
CTO

E: allard...@axoniq.io
T: +31 6 34 73 99 89

dule...@gmail.com

unread,
Oct 26, 2018, 9:43:17 PM10/26/18
to Axon Framework Users
Hello all,

Is there any updates on this? Just got the same result.
and puzzled what's the problem is.

在 2018年4月20日星期五 UTC+8下午10:28:16,ashutos...@metamagic.in写道:

Allard Buijze

unread,
Oct 29, 2018, 7:53:36 AM10/29/18
to axonfr...@googlegroups.com
It’s most likely because the message or metadata contains information that XStream cannot (de)serialize. There is probably a detailed stacktrace somewhere indicating where the problem is.
--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Renê Michels Rodrigues

unread,
Oct 29, 2018, 1:22:47 PM10/29/18
to Axon Framework Users
Probably because the commandGateway field declaration isn't transient.

Matthias Wesolowski

unread,
Dec 13, 2018, 4:39:28 PM12/13/18
to Axon Framework Users
Hi all,

I'm facing the same issue, but the logs dont show any useful information (at least for me). 
Attached the stacktrace. Do you have any idea? 

It happens when sending a new command within a saga. 
error_axon.log

Allard Buijze

unread,
Dec 13, 2018, 4:48:09 PM12/13/18
to axonfr...@googlegroups.com
Seems like XStream cannot serialize something.
The only ‘known issue’ with XStream related exceptions is when you have a Saga with a field that contains an infrastructure component which is not declared transient.
Note that the SagaTestFixture checks this.

Matthias Wesolowski

unread,
Dec 13, 2018, 4:52:23 PM12/13/18
to Axon Framework Users
Argh, you're right ... the CommandGateway wasn't marked as transient. Thanks for the hint ...

Siddalinga swamy

unread,
Feb 28, 2020, 6:53:02 AM2/28/20
to Axon Framework Users
hi @Allard

I am using Axon4.2 with Spring boot. Created simple saga. Its works well during Application running. However once it restarts, it re-runs the Saga again.

So Tried to use  MongoSagaStore for persisting SgagStore, did not work. Below are code snippet. Please help.


@Configuration
public class AxonConfig {

@Bean
@Primary
public Serializer serializer() {
final XStream xStream = new XStream(new CompactDriver());
xStream.setClassLoader(this.getClass().getClassLoader());
return XStreamSerializer.builder().xStream(xStream).build();
}
@Bean
public MongoSagaStore sagaStore(MongoClient client) {
MongoSagaStore.Builder builder = new MongoSagaStore.Builder();
builder.mongoTemplate(DefaultMongoTemplate.builder()
.mongoDatabase(client).build());
return builder.build();
}

MySagaClass
@Saga(sagaStore = "sagaStore")
public class DepositSaga {

@Autowired MongoTemplate mongoTemplate;

@StartSaga
@SagaEventHandler(associationProperty = "depositId")
public void handle(DepositStartEvent depositStartEvent ) {
logger.info("Saga invoked deposit Start Event ");

im getting Exception like this.

2020-02-28 16:53:39.904  INFO 20040 --- [mandProcessor-0] com.deposit.DepositAggregate   : Inside Deposit Start Command in DepositAggregate
2020-02-28 16:53:39.904  INFO 20040 --- [mandProcessor-0] com.deposit.DepositAggregate : Firing Deposit Start Event in DepositAggregate
2020-02-28 16:53:33.045  INFO 20040 --- [agaProcessor]-0] com.deposit.sagas.DepositSaga : Inside Saga Deposit Start Event in DepositSaga  
2020-02-28 16:53:39.904  INFO 20040 --- [mandProcessor-0] com.deposit.DepositAggregate  : Inside Deposit End Command in DepositAggregate
2020-02-28 16:53:43.753 WARN 20040 --- [agaProcessor]-0] in.axon.TrackingEventProcessor: Error occurred. Starting retry mode.

com.thoughtworks.xstream.converters.ConversionException: Failed calling method
---- Debugging information ----
message             : Failed calling method
cause-exception     : com.thoughtworks.xstream.converters.ConversionException
cause-message       : Failed calling method
method              : java.util.concurrent.CopyOnWriteArrayList.writeObject()
-------------------------------
at com.thoughtworks.xstream.core.util.SerializationMembers.callWriteObject(SerializationMembers.java:151) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.reflection.SerializableConverter.doMarshal(SerializableConverter.java:257) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:90) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshallField(AbstractReflectionConverter.java:274) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:144) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:90) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshallField(AbstractReflectionConverter.java:274) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:144) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:90) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshallField(AbstractReflectionConverter.java:274) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:144) ~[xstream-1.4.9.jar:1.4.9]

im getting Exception only when i am Using MongoSagaStore for re-running saga when application restart.

any configuration snippet to resolve the issue?

To unsubscribe from this group and stop receiving emails from it, send an email to axonfr...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Siddu

unread,
Feb 28, 2020, 12:31:41 PM2/28/20
to Axon Framework Users

i modified MongoSagaStore. below is the code snipped and it worked for me.
we need use builder.serializer(JacksonSerializer.defaultSerializer()); then we wont get that exception.

@bean
public SagaStore sagaRepository(MongoClient mongoClient) {


MongoSagaStore.Builder builder = new MongoSagaStore.Builder();
builder.mongoTemplate(DefaultMongoTemplate.builder()

.mongoDatabase(mongoClient).build());
builder.serializer(JacksonSerializer.defaultSerializer());
return builder.build();
}

thanks

Allard Buijze

unread,
Mar 1, 2020, 5:50:19 PM3/1/20
to Axon Framework Users
Hi Siddalinga,

the problem with the Saga getting the events again is probably the cause of the TokenStore being used. Axon defaults to Tracking Processing, and if it can't find any location to store the tokens in, it uses an InMemoryTokenStore. Try configuring a TokenStore implementation in your application context.

Hope this helps.
Cheers,

Allard Buijze
CTO


Reply all
Reply to author
Forward
0 new messages