I am using Java EE JMS Queue. I am sending objects into the queue and then receive them with a MDB. When reading the message body (with getBody()) into an object I get the following exception:
javax.jms.MessageFormatException: Body not assignable to class ...
Is there any way to get a more descriptive error out of this that would tell why exactly it is not assignable? I also tried to go into debug mode and see what kind of Message object arrives into the MDB but it is serialized as far as I can see so it's not really useful.
Object type is properly recognised in debugger before it is sent to the queue.
Additiona info: if I create an empty object manually and send it, it is properly recognised. The production object comes from a REST endpoint and contains a lot of properties and gets transformed a bunch of times in the process. Some piece of data must be preventing the assignment but debugging each property step by step would be a pain and only as a last resort.
Object is confirmed serializable per answer in how to test in Java that a class implements Serializable correctly (not just is an instance of Serializable)
Object is sent as:
jmsContext.createProducer().send(queue, object);
I managed to narrow it down by setting all properties to null and then commenting that out one by one until it worked. It turns out a Duration type property was improperly? initialized which caused the problem. And in another case it was XMLGregorianCalendar property that caused it. Still, this is a very hacky way of debugging and I still don't actually know why exactly the assignment fails, I just know which property causes it.
For the time being I ended up passing entity IDs into the queue instead of full objects and I retreive them from database by the ID instead.
Pastebin of full stacktrace: http://pastebin.com/vWvhDTcr