【问题标题】:ActiveMQ XStream ForbiddenClassExceptionActiveMQ XStream ForbiddenClassException
【发布时间】:2021-11-05 21:24:51
【问题描述】:

我在我的 java 应用程序中使用 ActiveMQ 5.16.2 作为代理和客户端 5.16.1。有时我会在循环中收到此错误:

---- Debugging information ----
cause-exception     : com.thoughtworks.xstream.security.ForbiddenClassException
cause-message       : java.io.IOException
class               : org.apache.activemq.command.ExceptionResponse
required-type       : org.apache.activemq.command.ExceptionResponse
converter-type      : 
com.thoughtworks.xstream.converters.reflection.ReflectionConverter
path                : /org.apache.activemq.command.ExceptionResponse/exception
line number         : 5
version             : 1.4.15
-------------------------------
    at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:34)
    at org.apache.activemq.transport.http.HttpClientTransport.run(HttpClientTransport.java:205)
    at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: com.thoughtworks.xstream.converters.ConversionException: 
---- Debugging information ----
cause-exception     : com.thoughtworks.xstream.security.ForbiddenClassException
cause-message       : java.io.IOException
class               : org.apache.activemq.command.ExceptionResponse
required-type       : org.apache.activemq.command.ExceptionResponse
converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
path                : /org.apache.activemq.command.ExceptionResponse/exception
line number         : 5
version             : 1.4.15
-------------------------------
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:77)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
    at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1409)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1388)
    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1273)
    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1264)
    at org.apache.activemq.transport.xstream.XStreamWireFormat.unmarshalText(XStreamWireFormat.java:66)
    at org.apache.activemq.transport.util.TextWireFormat.unmarshal(TextWireFormat.java:56)
    at org.apache.activemq.transport.http.HttpClientTransport.run(HttpClientTransport.java:196)
... 1 common frames omitted
Caused by: com.thoughtworks.xstream.security.ForbiddenClassException: java.io.IOException
   at com.thoughtworks.xstream.security.NoTypePermission.allows(NoTypePermission.java:26)
   at com.thoughtworks.xstream.mapper.SecurityMapper.realClass(SecurityMapper.java:74)
   at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125)
   at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:47)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:420)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
... 13 common frames omitted

当我在 5.16.0 中并在 5.16.1 中更正时,我已经在这个 XStream 中遇到了类似的错误,但现在是另一个错误。

我尝试使用 5.16.2 客户端,但我得到了同样的错误:

--- Debugging information ----
cause-exception     : 
com.thoughtworks.xstream.security.ForbiddenClassException
cause-message       : java.io.IOException
class               : org.apache.activemq.command.ExceptionResponse
required-type       : org.apache.activemq.command.ExceptionResponse
converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
path                : /org.apache.activemq.command.ExceptionResponse/exception
line number         : 5
version             : 1.4.16
-------------------------------

客户端发生异常。我们使用 XStream 是因为客户端通过 HTTP 连接,并且根据the documentation,此用例在客户端上需要 XStream。

这个应用程序已经在 TCP 中运行了很长时间,但我们也必须在 HTTPS 中使用它。由于我们一直在测试 HTTPS,我们遇到了一些奇怪的行为,测试由于 XStream 错误而失败,但其他 HTTPS 调用正常工作。我只是想弄清楚为什么切换到 HTTPS 会导致这种情况。

【问题讨论】:

  • 我没有在我的 maven 依赖中包含 xstream,它包含在 activemq 中,它尝试(我认为)读取数据并给我这个例外......
  • 我们只需在官方网站上下载 activemq 代理压缩包并解压缩,实际上,我在 lib/optional 中看到了 xstream(以及许多其他)...我在 lib 目录中没有它
  • 我们有这个问题,因为我们必须在 http 而不是在 tcp 中连接到 activemq
  • @JustinBertram 在客户端,所以我认为我不必将 jar 从可选移动到 lib
  • 这不是我的应用程序,因为我在这个问题上帮助同事,我只知道我们在这个应用程序中使用骆驼,也许是他隐含使用 xstream.. 我检查

标签: activemq xstream


【解决方案1】:

在我看来,XStream 正在尝试处理来自代理的 OpenWire org.apache.activemq.command.ExceptionResponse 消息。此消息包含一个序列化的java.io.IOException,而 XStream 无法转换它,因为它需要一个 XML 有效负载。这就是为什么异常说:

Caused by: com.thoughtworks.xstream.security.ForbiddenClassException: java.io.IOException

ForbiddenClassException 是 XStream 为响应无法转换的 java.io.IOException 而引发的异常。

目前尚不清楚是什么触发了java.io.IOException,因此值得调查(例如查看代理日志)。 XStream 失败本身似乎是一个错误。但是,我不确定 HTTP/S 传输的维护情况如何,因此可能不会很快提供错误修复(如果有的话)。您可以尝试从 ActiveMQ 5.x(即“经典”)迁移到 ActiveMQ Artemis,这也是 supports HTTP/S

【讨论】:

  • 好的,我会再次尝试搜索,如果我发现了什么,我会回复你。感谢您的帮助
猜你喜欢
  • 1970-01-01
  • 2018-09-11
  • 2015-04-30
  • 1970-01-01
  • 1970-01-01
  • 2015-06-18
  • 2016-03-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多