Mule2 and the IllegalArgumentException

This is the first of a series of short posts about issues we had when using Mule2 in a real project. The first issue I want to mention is the IllegalArgumentException. When we first ran into this exception we hadn’t really a clue where to look for the solution. After some investigation it appeared that the exception is raised when a components operation is called with the wrong type of argument.
Most likely this error:

Root Exception stack trace:
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.mule.transport.cxf.CxfMessageDispatcher.doSendWithProxy(CxfMessageDispatcher.java:176)

will occur if you forget to use a translator or the translator you configured doesn’t work as expected as was the case in our situation. We are receiving an XML file as a JMS message and wanted to translate this XML file to a Java object that we used as argument in our component. For the XML to Java translation we were relying on the default xml-to-object-translator. However we only got it working by using a custom translator that is using Jaxb2 for the translation as I described here.

About Pascal Alma

Pascal is a senior IT consultant and has been working in IT since 1997. He is monitoring the latest development in new technologies (Mobile, Cloud, Big Data) closely and particularly interested in Java open source tool stacks, cloud related technologies like AWS and mobile development like building iOS apps with Swift. Specialties: Java/JEE/Spring Amazon AWS API/REST Big Data Continuous Delivery Swift/iOS
This entry was posted in Mule and tagged , . Bookmark the permalink.