IllegalArgumentException with custom CommandBus

24 views
Skip to first unread message

teivah

unread,
Jun 21, 2017, 2:44:38 AM6/21/17
to Axon Framework Users
Hello all,

I'm facing a strange issue after having developed my own CommandBus implementation. The code is available right here: https://github.com/teivah/sky-centralrepository (develop branch).

Basically I implemented a JMSCommandBus and a JMSRequestSubscriber in charge to receive the commands and to manage the UOW events (onCommit, onRollback). When I run the unit tests, everything is working fine. 

Yet when I run my main method (the Post test class is then triggered after the application is configured), I am facing an exception in the JMSRequestSubscriber during the handler.handle(command) call. As I said, during unit tests this call in working fine but at runtime, the exception thrown is: java.lang.IllegalArgumentException: argument type mismatch. It's just like if my CommandHandler was not correctly registered..

If I change the CommandBus bean to the SimpleCommandBus, everything is working fine though.

Any idea guys?

Thanks!

Steven van Beelen

unread,
Jun 21, 2017, 3:41:55 AM6/21/17
to Axon Framework Users
Hi Teivah,

When you're debugging your application, do you see the @CommandHandler annotated functions being registered to your 'JMSCommandBus' through the 'subscribe(String commandName, MessageHandler<? super CommandMessage<?>> handler)'  function?
If that function isn't called at all, then none of the command handling functions are tied to your command bus, so no commands could be handled in that situation.

Hope this helps!

Cheers,

Steven

--
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.

teivah

unread,
Jun 21, 2017, 8:49:21 AM6/21/17
to Axon Framework Users
Thanks Steven for the comment.

Yet I've just found my problem. I was using the standard Java serialization to publish a JMS ObjectMessage. After investigation I figured out the payload of the GenericCommandMessage (let's call the class P) was not deserialized correctly. It lead to errors like "P cannot be cast to P".

The problem was related to Spring Boot devtools plugin! I'm not sure but even if the receiver and the sender were relying on the same ClassLoader (my test was running on the same JVM), it led to a serialization issue.. After disabling the plugin, everything is now working well.

Anyway that was not an Axon issue but I just wanted to share it if one day someone is facing the same problem.

Steven van Beelen

unread,
Jun 26, 2017, 4:42:20 AM6/26/17
to Axon Framework Users
No problem, and thanks for sharing the actual issue you had Teiva!

We're aware that the spring boot devtools plugin isn't always working nicely, but it's always good to hear another scenario around it.

Good luck with your further development!

Steven

--
Reply all
Reply to author
Forward
0 new messages