我一直在負責更新插件Cytoscape,生物可視化軟件平臺,到Cytoscape的API的最新版本。 Cytoscape 3.x使用OSGI框架(Karaf 2.2.x,我認爲)與其插件(現在稱爲「應用程序」)進行交互。的NoClassDefFoundError在使用JAX-WS在OSGi 4.2捆綁
的問題是,插件/應用程序使用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外工作。
有什麼建議嗎?我嘗試過使用Embed-Dependency
直接將JAX-WS API和/或實現類嵌入到包中,但這並沒有幫助。我也嘗試玩org.osgi.framework.system.packages.extra
和org.osgi.framework.bootdelegation
屬性,無濟於事。不過,我可能做錯了什麼。
恐怕OSGI可能被使用反射API的一些基本的不相容創建頭。但是,在這種環境下運行Web服務客戶端肯定不是不可能的,對吧?
不幸的是,我的短期問題還沒有結束。新問題在這裏:http://stackoverflow.com/questions/21706565/jax-ws-unmarshals-empty-objects-when-in-an-osgi-environment –