0

我是 Web 服务编程中的另一个菜鸟,遇到了一个未知错误:

我正在尝试使用 JaxWsDynamicClientFactory 来动态调用请求的服务(服务的地址及其参数是从文件中读取的,但这在这里无关紧要)。

问题是由 JaxWsDynamicClientFactory 的标准初始化引起的。

JaxWsDynamicClientFactory dcf= JaxWsDynamicClientFactory.newInstance();

执行此行后,Karaf (Felix) 返回以下错误:

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>
4

2 回答 2

0

在为符合 WS-I 的 WSDL 创建动态客户端时,我得到了相同的异常 java.lang.IllegalArgumentException。我相信这里报告的问题:

使用 JaxWsDynamicClientFactory 时出现 IllegalArgumentException

是原因。

于 2014-06-11T11:15:15.923 回答
0

CXF网站所述!

请注意,一般情况下,CXF 仅支持 WSI-BP 服务。如果您尝试为使用 WSI-BP 之外的功能的 WSDL 创建动态客户端,CXF 可能会引发异常。

这可能是你的问题。如果您右键单击绑定并选择:检查 WSI 合规性,请使用 SOAPUI 等工具进行检查

于 2014-04-18T17:40:37.167 回答