2014-03-12 104 views
0

我在Web服務編程一個更noobie誰面對一個未知的錯誤:動態客戶端生成java.lang.IllegalArgumentException異常錯誤

我試圖以動態調用請求的服務使用JaxWsDynamicClientFactory(中該服務的地址及其參數是從一個文件中讀取的,但這裏沒有關係)。

該問題是由JaxWsDynamicClientFactory的標準初始化引起的。

JaxWsDynamicClientFactory dcf= JaxWsDynamicClientFactory.newInstance(); 

此行Karaf(菲利克斯)的執行後返回以下錯誤:

java.lang.IllegalArgumentException: Can not set final com.sun.tools.internal.xjc 
.reader.internalizer.InternalizationLogic field com.sun.tools.internal.xjc.reade 
r.internalizer.DOMForest.logic to org.apache.cxf.endpoint.dynamic.DynamicClientF 
actory$1 
     at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(
UnsafeFieldAccessorImpl.java:146) 
     at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(
UnsafeFieldAccessorImpl.java:150) 
     at sun.reflect.UnsafeQualifiedObjectFieldAccessorImpl.set(UnsafeQualifie 
dObjectFieldAccessorImpl.java:65) 
     at java.lang.reflect.Field.set(Field.java:657) 
     at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.hackInNewInterna 
lizationLogic(DynamicClientFactory.java:817) 
     at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(Dyn 
amicClientFactory.java:314) 
     at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(Dyn 
amicClientFactory.java:270) 
     at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(Dyn 
amicClientFactory.java:263) 
     at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(Dyn 
amicClientFactory.java:198) 
     at testclient.BundleInvoker.invoke(BundleInvoker.java:53) 
     at testclient.TestClient.activate(TestClient.java:67) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. 
java:39) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces 
sorImpl.java:25) 
     at java.lang.reflect.Method.invoke(Method.java:597) 
     at org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.j 
ava:236) 
     at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.jav 
a:37) 
     at org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMetho 
d.java:613) 
     at org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:49 
6) 
     at org.apache.felix.scr.impl.helper.ActivateMethod.invoke(ActivateMethod 
.java:149) 
     at org.apache.felix.scr.impl.manager.ImmediateComponentManager.createImp 
lementationObject(ImmediateComponentManager.java:239) 
     at org.apache.felix.scr.impl.manager.ImmediateComponentManager.createCom 
ponent(ImmediateComponentManager.java:119) 
     at org.apache.felix.scr.impl.manager.AbstractComponentManager$Unsatisfie 
d.activate(AbstractComponentManager.java:1518) 
     at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateIn 
ternal(AbstractComponentManager.java:550) 
     at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(Abs 
tractComponentManager.java:261) 
     at org.apache.felix.scr.impl.config.ImmediateComponentHolder.enableCompo 
nents(ImmediateComponentHolder.java:328) 
     at org.apache.felix.scr.impl.BundleComponentActivator.initialize(BundleC 
omponentActivator.java:158) 
     at org.apache.felix.scr.impl.BundleComponentActivator.<init>(BundleCompo 
nentActivator.java:113) 
     at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:261 
) 
     at org.apache.felix.scr.impl.Activator.bundleChanged(Activator.java:179) 

     at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEv 
ent(BundleContextImpl.java:847) 
     at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventM 
anager.java:230) 
     at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchr 
onous(ListenerQueue.java:148) 
     at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent 
Privileged(Framework.java:1569) 
     at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent 
(Framework.java:1505) 
     at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent 
(Framework.java:1500) 
     at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(Bundl 
eHost.java:391) 
     at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(Abstrac 
tBundle.java:300) 
     at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(Di 
rectoryWatcher.java:1247) 
     at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(D 
irectoryWatcher.java:1219) 
     at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundle 
s(DirectoryWatcher.java:1208) 
     at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(Direct 
oryWatcher.java:503) 
     at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryW 
atcher.java:291) 

其實,我有以下執行(該程序繼續無任何影響)沒有問題,但我想要從屏幕上刪除這個令人討厭的錯誤堆棧。我嘗試通過try-catch環境來隱藏錯誤,但是Karaf完全忽略它(即,不會觸發catch部分,儘管會打印整個堆棧)。

你能幫我解決問題嗎(或者至少有助於理解爲什麼這個簡單的生產線)?

一般來說。代碼在Eclipse Kepler中創建,由Maven 2構建,並在Karaf(felix)中執行。這裏是從POM文件的依賴部分:

<dependencies> 
    <dependency> 
    <groupId>my.test.bundle</groupId> 
    <artifactId>test-interface</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    </dependency> 
    <dependency> 
    <groupId>org.apache.felix</groupId> 
    <artifactId>org.apache.felix.framework</artifactId> 
    <version>1.8.0</version> 
    <type>bundle</type> 
    </dependency> 
    <dependency> 
    <groupId>org.apache.felix</groupId> 
    <artifactId>org.osgi.core</artifactId> 
    <version>1.4.0</version> 
    <type>bundle</type> 
    </dependency> 
    <dependency> 
    <groupId>org.apache.cxf</groupId> 
    <artifactId>cxf-rt-frontend-jaxws</artifactId> 
    <version>2.7.8</version> 
    </dependency> 
</dependencies> 

回答

0

正如在CXF website

Note that, in general, CXF only supports WSI-BP services. If you attempt to create a dynamic client for a WSDL that uses features outside of WSI-BP, CXF may throw an exception.

這可能是你的問題。使用SOAPUI等工具檢查它是否右鍵單擊綁定並選擇:檢查WSI合規性