简体   繁体   English

代理无法使用可序列化类:在 ActiveMQ 中查看消息时出现 java.lang.ClassNotFoundException

[英]Serializable class not available to broker: java.lang.ClassNotFoundException while viewing messages in ActiveMQ

I want to see content of message which have been queued in ActiveMQ queues.我想查看已在 ActiveMQ 队列中排队的消息内容。 I opened web-console.( http://localhost:8161/admin/queues.jsp ) and clicked on message-id of the message of queue.我打开了 web-console。( http://localhost:8161/admin/queues.jsp ) 并单击了队列消息的 message-id。 It gives me following error in "Message Details" window rather than giving content of message.它在“消息详细信息”窗口中给我以下错误,而不是给出消息内容。

"javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException:" “javax.jms.JMSException:无法从内容构建正文。可序列化类对代理不可用。原因:java.lang.ClassNotFoundException:”

What is the cause of this exception & what I need to do to get rid of this?这个异常的原因是什么以及我需要做些什么来摆脱这个?

I have seen this same error using ActiveMQ version 5.8.0 我使用ActiveMQ版本5.8.0看到了同样的错误

In my case it was a red herring , the ActiveMQ console could not unserialize the message it mustn't have access to the jar that the class is in, but the consumer application does, and the message is passed on without issue from the queue to the consumer. 在我的情况下,它是一个红色的鲱鱼 ,ActiveMQ控制台无法反序列化它必须无法访问该类所在的jar的消息,但消费者应用程序会这样做,并且消息从队列传递到没有问题消费者。

I'd be interested to see if there's a solution to the issue here (viewing the message in the console), and also how this is handled in more recent versions of ActiveMQ. 我有兴趣看看这个问题是否有解决方案(在控制台中查看消息),以及如何在更新版本的ActiveMQ中处理这个问题。

As OwIR mentioned, you need to set the path of the jar file containing the classes onto the wrapper.java.classpath.3 property in %ACTIVEMQ_HOME%\\bin\\win64\\wrapper.conf . 正如OwIR所提到的,您需要将包含类的jar文件的路径设置到%ACTIVEMQ_HOME%\\bin\\win64\\wrapper.conf wrapper.java.classpath.3中的wrapper.java.classpath.3属性中。

You might encounter the below exception after updating the above property 更新上述属性后,您可能会遇到以下异常

Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: Forbidden class

In order to fix it, set the wrapper.java.additional.13 property to -Dorg.apache.activemq.SERIALIZABLE_PACKAGES="<choose_the_packages_set_it_here>" 要修复它,请将wrapper.java.additional.13属性设置为-Dorg.apache.activemq.SERIALIZABLE_PACKAGES="<choose_the_packages_set_it_here>"

You could also use -Dorg.apache.activemq.SERIALIZABLE_PACKAGES="*" as the value, however it might be unsafe to use wildcard. 您也可以使用-Dorg.apache.activemq.SERIALIZABLE_PACKAGES="*"作为值,但使用通配符可能不安全。

This worked for me!! 这对我有用!! Hope it helps you 希望它能帮到你

If you are sending class, in this case you will face this issue.

For example: customer is my class object and when you try to see the infomation it gives you error:
Serializable class not available to broker: java.lang.ClassNotFoundException while viewing messages in ActiveMQ

jmsTemplate.convertAndSend(jmsDestination,customer);

The Solution of this problem is ("toString()") method along with class.

Solution: jmsTemplate.convertAndSend(jmsDestination,customer.toString());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM