javax.jms.JMSException: Failed to build body from content. Serializable class not available to broke
2016-07-19 15:11
716 查看
javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker.
Reason: java.lang.ClassNotFoundException: com.syx.producter.model.InfoModel
http://activemq.apache.org/objectmessage.html
造成这个错误的原因是ActiveMQ的ObjectMessage依赖于Java的序列化和反序列化,但是这个过程被认为是不安全的。所以ActiveMQ就强制用户使用完整路径的ObjectMessages来进行交换。(就是把发送方的包添加到接收方的代码中去)
如果你需要使用自定义的ObjectMessage,就要把这个ObjectMessage类添加到应用中。
官方还提供了其他的解决办法
在ActiveMQ中设置:
在activemq.bat的ACTIVE_OPTS中添加下面一段代码
Linux是:apache-activemq-5.13.0\bin\activemq
在客户端设置:
1、暂时关闭安全检查,选择相信所有的包
改用官方的
2、添加信任包在到trustAllPackages中
然后我想着按提示报错的信息,就是说这个包下面没找到类不是,那我就去创建一个不就解决了(最初我就这么做,并且接收到了消息,使用的不是5.13.3版本的包)。
然后我就创建了这么个类,并且重启了服务,然后就出现了个新错误,说这个类不被信任
Forbidden class com.syx.producter.model.InfoModel! This class is not trusted to be serialized as ObjectMessage payload. Please take a look at http://activemq.apache.org/objectmessage.html for more information on how to configure trusted classes.
我真的是日了狗了,到底要怎么解决啊。还让我去看那鬼连接。
还是老老实实的去用json传递数据吧,这ObjectMessage就是个巨坑。
Reason: java.lang.ClassNotFoundException: com.syx.producter.model.InfoModel
http://activemq.apache.org/objectmessage.html
造成这个错误的原因是ActiveMQ的ObjectMessage依赖于Java的序列化和反序列化,但是这个过程被认为是不安全的。所以ActiveMQ就强制用户使用完整路径的ObjectMessages来进行交换。(就是把发送方的包添加到接收方的代码中去)
如果你需要使用自定义的ObjectMessage,就要把这个ObjectMessage类添加到应用中。
官方还提供了其他的解决办法
在ActiveMQ中设置:
在activemq.bat的ACTIVE_OPTS中添加下面一段代码
-Dorg.apache.activemq.SERIALIZABLE_PACKAGES="*"windows环境路径:apache-activemq-5.13.0\bin\activemq.bat 和activemq-admin.bat
Linux是:apache-activemq-5.13.0\bin\activemq
在客户端设置:
1、暂时关闭安全检查,选择相信所有的包
改用官方的
<bean id="connectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory"> <property name="brokerURL" value="tcp://localhost:61616"/> <property name="trustAllPackages" value="true"/> </bean> <bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration"> <property name="connectionFactory" ref="connectionFactory"/> </bean> <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent"> <property name="configuration" ref="jmsConfig"/> </bean>
2、添加信任包在到trustAllPackages中
<bean id="connectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory"> <property name="brokerURL" value="tcp://localhost:61616"/> <property name="trustedPackages"> <list> <value>org.apache.activemq.test</value> <value>org.apache.camel.test</value> </list> </property> </bean> <bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration"> <property name="connectionFactory" ref="connectionFactory"/> </bean> <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent"> <property name="configuration" ref="jmsConfig"/> </bean>经过这么一折腾,根本没暖用,不知道是不是我设置的问题,/(ㄒoㄒ)/~~。真的是被搞疯了。
然后我想着按提示报错的信息,就是说这个包下面没找到类不是,那我就去创建一个不就解决了(最初我就这么做,并且接收到了消息,使用的不是5.13.3版本的包)。
然后我就创建了这么个类,并且重启了服务,然后就出现了个新错误,说这个类不被信任
Forbidden class com.syx.producter.model.InfoModel! This class is not trusted to be serialized as ObjectMessage payload. Please take a look at http://activemq.apache.org/objectmessage.html for more information on how to configure trusted classes.
我真的是日了狗了,到底要怎么解决啊。还让我去看那鬼连接。
还是老老实实的去用json传递数据吧,这ObjectMessage就是个巨坑。
相关文章推荐
- Android开发技术周报 Issue#19
- 375. Guess Number Higher or Lower II
- break、continue、return之间的区别与联系
- Android开发技术周报 Issue#20
- Android开发技术周报 Issue#22
- Android开发技术周报 Issue#23
- Android开发技术周报 Issue#24
- Android开发技术周报 Issue#25
- IOS 开发使用UIStoryBoard时如何隐藏UITableViewController中的Section
- Android开发技术周报 Issue#26
- Android开发技术周报 Issue#27
- Android开发技术周报 Issue#28
- UIImageView图片填充三种模式的区别
- Android开发技术周报 Issue#29
- ToUInt32(string value, int fromBase);
- Android开发技术周报 Issue#30
- UGUI如何在UI与UI直接穿插粒子特效和模型
- Android开发技术周报 Issue#31
- 《设计模式》之Creational模式:Builder
- confluence迁移