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.