JAX-WS无法在OSGI环境中解组 [英] JAX-WS fails to unmarshal in an OSGI environment

查看:141
本文介绍了JAX-WS无法在OSGI环境中解组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的任务是将生物可视化软件平台 Cytoscape 的插件更新到最新版本版本的Cytoscape API. Cytoscape 3.x使用OSGI框架(我认为是Karaf 2.2.x)与其插件(现在称为应用")进行交互.

I've been tasked with updating a plugin for Cytoscape, a biological visualization software platform, to the latest version of the Cytoscape API. Cytoscape 3.x uses an OSGI framework (Karaf 2.2.x, I think) to interface with its plugins (which are now called "apps").

插件/应用程序实际上是使用JAX-WS与外部服务器进行通信的客户端.但是由于某种原因,尽管没有任何错误消息,它也无法解组所收到的SOAP消息.所需的对象是使用默认构造函数创建的,但是它们的字段保持为空.

The plugin/app is actually a client that uses JAX-WS to communicate with an external server. But for some reason, despite the absence of any error messages, it fails to unmarshal the SOAP messages that it's getting. The desired objects are created with the default constructor, but their fields remain empty.

我可以确认XML 确实确实是从服务器到达的.我还可以确认相同的代码可以在非OSGI环境中使用.此外,同时为OSGI和非OSGI版本启用jaxb.debug JVM选项表明,在两种情况下,JAXB似乎都在幕后做同样的事情.

I can confirm that the XML does arrive from the server in one piece. I can also confirm that this same code works in a non-OSGI environment. Furthermore, enabling the jaxb.debug JVM option for both the OSGI and non-OSGI versions shows that JAXB appears to be doing the exact same things behind the scenes in both cases.

所以,我不知道这是怎么回事.有什么想法吗?

So, I have no idea what's going on here. Any ideas?

更新:

经过进一步调查,我确定该问题可能与JAX-WS根本没有任何关系.我将来自Web服务的SOAP消息作为XML文件保存在硬盘上.试图直接取消封送而不完全不使用Web服务,则导致以下情况:

After further investigation, I've determined that the problem may not have anything directly to do with JAX-WS at all. I saved the SOAP message that arrives from the web service as an XML file on my hard drive. Attempting to directly unmarshal it, without touching the web service at all, caused this:

Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: javax.xml.stream.XMLInputFactory.newFactory()Ljavax/xml/stream/XMLInputFactory;

再一次,同样的代码在独立的非OSGI环境中也可以正常工作.很奇怪.

Once again, this same code works fine in a standalone non-OSGI environment. Very strange.

推荐答案

我想我已经找到了解决方案.

I think I've found a solution.

我添加了

I added the Apache ServiceMix Stax API 1.2 bundle to the Cytoscape OSGI container, and then used Import-Package to import its javax.xml.stream package into my own bundle, making sure to require version 1.2 and up.

默认情况下,Cytoscape似乎提供了javax.xml.stream.XMLInputFactory的过时(Java 5?)版本,这是我所有问题的根源.它实际上并没有使我的手动解组代码工作(仍然存在一些怪异的API/实现版本不匹配引发了异常),但是原始的Web服务代码却可以.

It seems that Cytoscape by default provides an out of date (Java 5?) version of javax.xml.stream.XMLInputFactory, and that this was the source of all my problems. It didn't actually make my manual unmarshalling code work (there were still some weird API/implementation version mismatches that threw exceptions) but the original web service code did.

这篇关于JAX-WS无法在OSGI环境中解组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆