1. 程式人生 > >解決Spring集成Activemq使用ObjectMessage報錯

解決Spring集成Activemq使用ObjectMessage報錯

tor 添加 1.5 nested eas 但是 prop pro form

**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報錯