ActiveMQ :Serializable class not available to broker.

简介: 错误信息javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker.

错误信息

javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: Forbidden class com.mazaiting.jms.converter.Email! 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.
    at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:36)
    at org.apache.activemq.command.ActiveMQObjectMessage.getObject(ActiveMQObjectMessage.java:213)
    at com.mazaiting.jms.converter.listener.ConsumerMessageListener.onMessage(ConsumerMessageListener.java:26)
    at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:746)
    at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:684)
    at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:651)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:317)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:255)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1166)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1158)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1055)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Forbidden class com.mazaiting.jms.converter.Email! 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.
    at org.apache.activemq.util.ClassLoadingAwareObjectInputStream.checkSecurity(ClassLoadingAwareObjectInputStream.java:112)
    at org.apache.activemq.util.ClassLoadingAwareObjectInputStream.resolveClass(ClassLoadingAwareObjectInputStream.java:57)
    at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
    at java.io.ObjectInputStream.readClassDesc(Unknown Source)
    at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)
    at org.apache.activemq.command.ActiveMQObjectMessage.getObject(ActiveMQObjectMessage.java:211)
    ... 10 more
img_ae5d868ecf9fc7e1e4dc0136cafd75c9.png
异常.png

错误原因

ActiveMQ未允许传输序列化对象

解决方法

在targetConnectionFactory中添加

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

完整配置

    <!-- 真正可以产生Connection的ConnectionFactory,由对应的JMS服务厂商提供 -->
    <bean id="targetConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="tcp://localhost:61616"/>
        <!-- 如果传输对象,必须设置这句为true -->
        <property name="trustAllPackages" value="true"/>
    </bean>
img_d79e9764365e66184bfdaacc27509b12.png
解决.png
目录
相关文章
|
消息中间件 存储 算法
聊聊 Kafka: Consumer 源码解析之 Consumer 如何加入 Consumer Group
聊聊 Kafka: Consumer 源码解析之 Consumer 如何加入 Consumer Group
1023 0
|
消息中间件 JSON Java
RabbitMQ竟然无法反序列化List
最近在接到了一个需求,大概是通过RabbitMq给xx子系统同步用户数据,要提供单个同步和批量同步。内心暗喜这不简单的很嘛。三下五除二就把代码给写完了但是在联调的过程中,遇到了一个比较奇葩的问题。单个用户进行同步时,子系统可以正常消费。然后进行批量同步的时候,子系统报错了。并抛出java.lang.ClassCastException提示 LinkedHashMap cannot xxxx class 。于是负责子系统的哥们笑嘻嘻的(表面笑嘻嘻)走过来对我说,不是约定List 为啥发个Map过来?看到这个错误,着实让我摸不到头脑。顿时一堆疑问用上心头, 为啥单个对象可以,List就不行
RabbitMQ竟然无法反序列化List
|
消息中间件 JSON Java
Apache Kafka-SpringBoot整合Kafka发送复杂对象
Apache Kafka-SpringBoot整合Kafka发送复杂对象
322 0
Apache Kafka-SpringBoot整合Kafka发送复杂对象
|
消息中间件 JSON Java
Apache Kafka-Spring Kafka将泛型反序列化为对象而非LinkedHashMap
Apache Kafka-Spring Kafka将泛型反序列化为对象而非LinkedHashMap
135 0
|
消息中间件 Java
SpringBoot整合ActiveMq实现Queue和Topic两种模式
SpringBoot整合ActiveMq实现Queue和Topic两种模式
136 4
SpringBoot整合ActiveMq实现Queue和Topic两种模式
|
XML Java 程序员
zookeeper源码分析--序列化篇
zookeeper源码分析--序列化篇
172 0
|
消息中间件 数据安全/隐私保护
ActiveMQ消息中间件Producer和Consumer
生产者代码: package com.java1234.activemq; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.MessageProdu
4006 1
|
消息中间件 Kafka Perl
class kafka.common.NotLeaderForPartitionException(kafka.server.ReplicaFetcherThread)异常处理
  [2017-06-15 19:33:14,716] ERROR [ReplicaFetcherThread-0-0], Error for partition [3_7_0_20170615,6] to broker 0:class kafka.
2748 0
|
消息中间件 Kafka 安全
读Kafka Consumer源码
最近一直在关注阿里的一个开源项目:OpenMessaging OpenMessaging, which includes the establishment of industry guidelines and messaging, streaming specifications to pr...
908 0