6 Replies Latest reply on Nov 15, 2011 2:16 AM by wdfink

    javax.jms.MessageFormatException: Object cannot be serialized

    ohmygod

      Hi everybody here,

       

      I am not sure if I am putting this question the correct location, but I am eager to know the answer. Could someone give me some suggestion about this problem?

       

      I am passing an object to create an ObjectMessage, but there is a problem. First see the code below.

       

      session = m_topicConnection.createTopicSession(false,

                      Session.CLIENT_ACKNOWLEDGE);

      TopicPublisher sender = session.createPublisher(topic);

      ObjectMessage om = session.createObjectMessage(myObject);

       

      In myObject, there is a HashMap member. Then the problem is when I put an Exception object (self created object extending RuntimeException) to the HashMap and try to create the ObjectMessage, there is such error reported:

      javax.jms.MessageFormatException: Object cannot be serialized

                at org.jboss.mq.SpyObjectMessage.setObject(SpyObjectMessage.java:83)

                at org.jboss.mq.SpySession.createObjectMessage(SpySession.java:306)

       

      When I do not put the Exception object in the HashMap, there will not be such error.

       

      Note that I have implemented Serializable in the Exception object.

       

      Is there any suggestion about this problem? Thanks in advance.