I'm not an experienced Java developer. I'm trying to send an Object Message using JMS to ActiveMQ. The message is failing to process in AMQ with exception that local class serial version doesn't match with stream classdesc. I have explicitly defined the serialVersionUID
in my serialize class. Don't know what is the issue. Please guide me with this.
Exception: javax.jms.JMSException: Failed to build body from bytes. Reason: java.io.InvalidClassException: com.mypkg.PaymentMessage; local class incompatible: stream classdesc serialVersionUID = 10020120822, local class serialVersionUID = 8437680918200181
PaymentMessage.java:
public class PaymentMessage implements Serializable {
private static final long serialVersionUID=10020120822L;
private String mymsg;
public String getPaymentMessage()
{
return mymsg;
}
public void setPaymentMessage(String mymsg)
{
this.mymsg=mymsg;
}
}
jmsSend.java:
public class jmsSend {
public static void main(String args[]) {
String strmsg = "Sample message";
try {
ConnectionFactory cf = new ActiveMQConnectionFactory("tcp://XXXX");
Connection connection = cf.createConnection();
connection.start();
Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue("myqueue");
MessageProducer producer = session.createProducer(queue);
PaymentMessage msg = new PaymentMessage();
msg.setPaymentMessage(strmsg);
ObjectMessage objmsg = session.createObjectMessage(msg);
producer.send(objmsg);
session.close();
} finally {
if (connection!=null) {
connection.close();
}
}
}
}
EDIT - The above error is from the consumer which validates/processes the messages. The application has its own java client to generate test messages which won't be supported in future. So trying to create and send messages manually. The server side jars won't match to my local but I tried to name the packages as same and copied the serialVersionUID from the original client.