【发布时间】: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.. 我检查