IllegalArgumentException with custom CommandBus

Hello all,

I’m facing a strange issue after having developed my own CommandBus implementation. The code is available right here: (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?


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!



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.

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!