我的任务是将Cytoscape的插件(一个生物可视化软件平台)更新到最新版本的 Cytoscape API。Cytoscape 3.x 使用 OSGI 框架(我认为是 Karaf 2.2.x)与其插件(现在称为“应用程序”)进行交互。
问题在于插件/应用程序使用 JAX-WS 与外部服务器通信,而 JAX-WS 在 OSGI 环境中加载类似乎存在问题。
这是有问题的代码片段:
public class AnatServerService extends Service {
@WebEndpoint(name = "AnatServerPort")
public AnatServerIfc getServerPort() {
AnatServerIfc port = super.getPort(new QName("network", "AnatServerPort"), AnatServerIfc.class);
((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, path);
return port;
}
}
这是由此产生的异常:
java.lang.NoClassDefFoundError: com.sun.xml.internal.ws.api.message.Header not found by AnatApp [168]
at com.sun.proxy.$Proxy64.<clinit>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.reflect.Proxy.newInstance(Unknown Source)
at java.lang.reflect.Proxy.newProxyInstance(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.xml.internal.ws.client.WSServiceDelegate.createProxy(UnknownSource)
at com.sun.xml.internal.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(Unknown Source)
at javax.xml.ws.Service.getPort(Unknown Source)
at anat.ws.AnatServerService.getServerPort(AnatServerService.java:36)
at anat.task.AvailableNetworksTask.getAvailableNetworks(AvailableNetworksTask.java:39)
at anat.task.AvailableNetworksTask.run(AvailableNetworksTask.java:62)
at org.cytoscape.work.internal.sync.SyncTaskManager.execute(SyncTaskManager.java:86)
at anat.view.BackgroundDefinitionDialog$AvailableNetworksSwingWorker.doInBackground(BackgroundDefinitionDialog.java:1544)
at anat.view.BackgroundDefinitionDialog$AvailableNetworksSwingWorker.doInBackground(BackgroundDefinitionDialog.java:1535)
at javax.swing.SwingWorker$1.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at javax.swing.SwingWorker.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
我可以确认此代码在 OSGI 之外确实有效。
有什么建议么?我尝试过使用 将 JAX-WS API 和/或实现类直接嵌入到包中Embed-Dependency
,但这没有帮助。我也尝试过使用org.osgi.framework.system.packages.extra
andorg.osgi.framework.bootdelegation
属性,但无济于事。不过,我可能做错了什么。
我担心 OSGI 可能与用于创建该标头的反射 API 存在一些根本不兼容。但是在这种环境下运行 Web 服务客户端肯定不是不可能的,对吧?