Search code examples
javaserializationjmstibco

Sending Serializable objects via a Tibco JMS throws a Deserialization failed error


I have a java application that sends a simple java bean over JMS to another java application.

This work completely fine ActiveMQ, but when I switch to Tibco JMS Broker an error is thrown on the receiving application. The bean implements the Serializable interface, and both application are running from the same jars which contains the class for the bean.

I start Tibco JMS using tibjmsd.exe. The version is 4.1.0.

A simple check from within the sending java client generates the error below:

Code:

..
....
MyBean bean = new MyBean(1,”Test”);
final ObjectMessage msg = jmssession.createObjectMessage(bean);
    try {
        msg.getObject();
    } catch (Exception e) {
        LOG.error("Problem with storing bean", e);
    }
....
..

The error message from the above code:

javax.jms.MessageFormatException: Deserialization failed: [Ljava.lang.String;
     at com.tibco.tibjms.TibjmsObjectMessage.getObject(TibjmsObjectMessage.java:199)

The same code work without error running a ActiveMQ Is there something i can do or check ?


Solution

  • First of all, you need to find out the linkedException for that JMSException

    catch(MessageFormatException mfe)
    {
          mfe.printStackTrace(); // what you told us
          mfe.getLinkedException().printStackTrace(); // the interesting one
    }
    

    I have the feeling this will be related to their TibjmsObjectMessage$CLOIS.resolveClass inability to parse classnames correctly for native arrays.

    It seems that some are having trouble to have even a simple long in their message: https://jira.springsource.org/browse/SPR-1231?page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel

    And a suggested solution, which would work, is to serialize the object yourself and use javax.jms.BytesMessage.