解决Spring集成Activemq使用ObjectMessage报错
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决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>
以上是关于解决Spring集成Activemq使用ObjectMessage报错的主要内容,如果未能解决你的问题,请参考以下文章
使用 Spring、ActiveMQ 和 Qpid 进行集成测试