解决Spring集成Activemq使用ObjectMessage报错

**Exception in thread “main” org.springframework.jms.UncategorizedJmsException: Uncategorized exception occured during JMS processing; nested exception is javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: Forbidden class SpringActivemq.ActivemqTest.Person! This class is not trusted to be serialized as ObjectMessage payload.

*原因:是ActiveMQ的ObjectMessage依赖于Java的序列化和反序列化,但是这个过程被认为是不安全的。具体信息查看网址:
Please take a look at http://activemq.apache.org/objectmessage.html for more information on how to configure trusted classes.

解决方法:
<bean id=”connectionFactory” class=”org.apache.activemq.ActiveMQConnectionFactory”>
<property name=”brokerURL”>
<value>tcp://198.201.51.131:61616</value>
</property>
<!– 添加信任包在到trustAllPackages –>
<property name=”trustAllPackages” value=”true”/> **

<property name=”userName”>
<value>admin</value>
</property>
<property name=”password”>
<value>admin</value>
</property>
</bean>

    本文转自爱情89757 51CTO博客,原文链接:http://blog.51cto.com/59465168/2071952,如需转载请自行联系原作者

点赞