How to debug JMS when Body is not assigned to a class?

I am using Java EE JMS Queue. I send objects to the queue and then get them using MDB. When reading the message body (with getBody ()) into the object, the following exception occurs:

javax.jms.MessageFormatException: Body not assignable to class ... 

Is there a way to get a more descriptive error from this that will explain why it cannot be assigned? I also tried to enter debug mode and see which message object arrives in MDB, but it is serialized as far as I can see, so it is not very useful.

The type of object is properly recognized in the debugger before it is sent to the queue.

Additional information: if I create an empty object manually and send it, it will be correctly recognized. The production object comes from the REST endpoint and contains many properties and is transformed in the process. Some of the data should interfere with the assignment, but debugging each property step by step would be a pain and only as a last resort.

The object is confirmed serializable for each answer in how to test in Java that the class implements Serializable correctly (not just an instance of Serializable)

The object is sent as: jmsContext.createProducer().send(queue, object);

I managed to narrow it down by setting all the properties to null and then commenting it out one by one until it works. Turns out a property of type Duration was wrong? what caused the problem. And in another case, it called the XMLGregorianCalendar property. However, this is a very hacky way of debugging, and I still don’t know why the assignment fails, I just know which property calls it.

Currently, I have finished queuing entity identifiers instead of complete objects, and instead I am returning them from the database by identifier.

Pastebin full stacktrace: http://pastebin.com/vWvhDTcr

+7
java debugging java-ee jms
source share
2 answers

Good design (if you have control over it now, that is, its new application is no longer ready), you may need to use json files, so you can see the payload as text at any time, json deserializers, for example jackson, spit out best exceptions.

Gregorian calendars are painful for serializing xml, at least from my experience, you'd better use something like joda style time.

+1
source share

The entire graph of the objects you put in the queue must be imported and accessible in the MDB. Including a standard format like java.util.GregorianCalendar

0
source share

All Articles