0

我正在使用 apache camel 2.12.0(也尝试过 2.14.0)。我有一条从远程服务器接收 xml 的路由:

<?xml version='1.0' encoding='UTF-8'?> <response><meta><code>200</code></meta><data><person><name>John</name></person></data></response>

from("direct:start")
.to("jetty:http://localhost/something")
.transform().xpath("/response/data")
.log("${body.class}")
.unmarshal().xstream();

我切出解组它的身体。使用 xstream。

.log("${body.class}") -> net.sf.saxon.dom.DOMNodeList

到目前为止,一切正常。mvn test, mvn camel:run .. 都很好。

现在是错误部分

mvn cobertura:cobertura抛出异常

org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream but has value: [net.sf.saxon.tree.tiny.TinyElementImpl@90400f] of type: java.util.ArrayList on: Message: [net.sf.saxon.tree.tiny.TinyElementImpl@90400f]

.log("${body.class}") -> java.util.ArrayList

帮助

您能否给出一个建议,为什么 cobertura 会更改 xpath() 的返回类型?

更新(已解决)

我发现了依赖关系的问题。如果我使用 camel-xstream 和 cobertura,我会在 .xpath() 中出现奇怪的行为。但是,如果我在依赖项中还包含 camel-xmljson 库,那么一切正常。我想 coberturas 对 jaxen:jaxen:jar:1.1-beta-8:compile 的依赖之一或其他一些加载与骆驼碰撞的 xml 类。

4

0 回答 0