I had a piece of code which was working fine in 6.2.0 version , the code was to simply drop a Java Serialized object in to AMQ and then read it back.The class is as below
package com.sundar.verify;
import java.io.Serializable;
public class MyBean implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private String id;
private String textData;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTextData() {
return textData;
}
public void setTextData(String textData) {
this.textData = textData;
}
}
with a camel route <camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="timer:foo?repeatCount=1&delay=10000" />
<process ref="mybean" />
<to uri="activemq:personnel.records" />
</route>
<route>
<from uri="activemq:personnel.records" />
<log message="Body is ${body}" />
</route>
</camelContext>
This was obsolutely working fine with Fuse 6.2.0 , but when the same code was migrated to 6.2.1 , I suddenly started to notice that the below exception was thrown
Caused by: javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: Forbidden class com.sundar.verify.MyBean! This class is not allowed to be serialized. Add package with 'org.apache.activemq.SERIALIZABLE_PACKAGES' system property.
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:36)
at org.apache.activemq.command.ActiveMQObjectMessage.getObject(ActiveMQObjectMessage.java:193)
at org.apache.camel.component.jms.JmsBinding.extractBodyFromJms(JmsBinding.java:126)
... 23 more
To prevent this from happening and for the deserilazation to work propertly add the below system property on the client side as below-Dorg.apache.activemq.SERIALIZABLE_PACKAGES="java.lang,java.util,org.apache.activemq,org.fusesource.hawtbuf,
com.thoughtworks.xstream.mapper,<your-package-names>"
and for the impatient-Dorg.apache.activemq.SERIALIZABLE_PACKAGES="*"
In case if you are running the consumer on a fabric container , set the JVM props on the container as in the image below