Failed to build body from content. Serializable class not available to broker

Recently I was updated spring platform version from 2.0.1.RELEASE to 2.0.5.RELEASE. My JMS module is encounter the following exception.

AbstractMessageListenerContainer.invokeErrorHandler:936 Execution of JMS message listener failed, and no ErrorHandler has been set.

And

Caused by: javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker.
Reason: java.lang.ClassNotFoundException: Forbidden class com.codeomitted.model.GTranxMessage! This class is not trusted to be serialized as ObjectMessage payload.

After couple of minutes investigate, just found out, ActiveMQ enforce user to whitelist the package for security reason. The solution for me is quite easy, which include the property trustedPackages with my package name.

<bean id="connectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory">
    <property name="brokerURL" value="tcp://localhost:61616"/>
    <property name="trustedPackages">
        <list>
            <value>com.codeomitted.model/value>
        </list>
    </property>
</bean>

OR to whitelist all package.

<property name="trustAllPackages" value="true"/>

 

For more details, visit the http://activemq.apache.org/objectmessage.html activemq site.

 

Failed to build body from content. Serializable class not available to broker

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.