【问题标题】:SoapBindingFactory not present using Apache CXF on Karaf with SpringSoapBindingFactory 不存在在带有 Spring 的 Karaf 上使用 Apache CXF
【发布时间】:2014-01-20 08:44:36
【问题描述】:

我正在开发一个应用程序,我需要在其中使用来自网络服务的数据。

此应用程序在 Karaf 容器上运行并使用 Spring。

我有 wsdl 文件并使用 JAX-WS 从 wsdl 生成源。如果我启动一个使用服务的 JUnit 测试,一切正常,但是在 Karaf 容器上启动应用程序时,会出现以下错误:

Caugth exception of type javax.xml.ws.WebServiceException with message org.apache.cxf.service.factory.ServiceConstructionException 
javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
    at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:345)
    at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:334)
    at javax.xml.ws.Service.getPort(Service.java:46)[:2.3.xxxxxxx]
    at es.repartoxxxxxxxclient.view.webservice.pedido.PedidoService_Service.getPedidoService(PedidoService_Service.java:77)
    at es.repartoxxxxxxxclient.view.webservice.pedido.PedidoService_Service$getPedidoService.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
    at es.xxxxxxx.devices.deliveries.EWhereDevice.getClient(EWhereDevice.groovy:66)
    at es.xxxxxxx.devices.deliveries.DeliveriesProcessor$getClient.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at es.xxxxxxx.devices.deliveries.DeliveriesDevice.getClient(DeliveriesDevice.groovy:79)
    at es.xxxxxxx.devices.deliveries.DeliveriesProcessor$getClient.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at es.xxxxxxx.devices.deliveries.PedidosDeviceService.getClient(PedidosDeviceService.groovy:36)
    at org.xxxxxxx.devices.service.DeliveriesDeviceService$getClient.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at org.xxxxxxx.business.deliveries.impl.DeliveriesServiceImpl.getClient(DeliveriesServiceImpl.groovy:88)
    at org.xxxxxxx.business.deliveries.DeliveriesService$getClient.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at VIEW.DatosClientePedidosView$_closure1.doCall(DatosClientePedidosView.groovy:240)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_07]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_07]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_07]
    at java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_07]
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1047)
    at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:877)
    at groovy.lang.Closure.call(Closure.java:412)[68:groovy-all:1.8.6]
    at org.codehaus.groovy.runtime.ConvertedClosure.invokeCustom(ConvertedClosure.java:51)
    at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:82)
    at $Proxy204.keyPressed(Unknown Source)
    at java.awt.AWTEventMulticaster.keyPressed(AWTEventMulticaster.java:250)[:1.7.0_07]
    at java.awt.Component.processKeyEvent(Component.java:6463)[:1.7.0_07]
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2829)[:1.7.0_07]
    at java.awt.Component.processEvent(Component.java:6282)[:1.7.0_07]
    at java.awt.Container.processEvent(Container.java:2229)[:1.7.0_07]
    at java.awt.Component.dispatchEventImpl(Component.java:4861)[:1.7.0_07]
    at java.awt.Container.dispatchEventImpl(Container.java:2287)[:1.7.0_07]
    at java.awt.Component.dispatchEvent(Component.java:4687)[:1.7.0_07]
    at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1895)[:1.7.0_07]
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:762)[:1.7.0_07]
    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1027)[:1.7.0_07]
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:899)[:1.7.0_07]
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:727)[:1.7.0_07]
    at java.awt.Component.dispatchEventImpl(Component.java:4731)[:1.7.0_07]
    at java.awt.Container.dispatchEventImpl(Container.java:2287)[:1.7.0_07]
    at java.awt.Window.dispatchEventImpl(Window.java:2719)[:1.7.0_07]
    at java.awt.Component.dispatchEvent(Component.java:4687)[:1.7.0_07]
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)[:1.7.0_07]
    at java.awt.EventQueue.access$200(EventQueue.java:103)[:1.7.0_07]
    at java.awt.EventQueue$3.run(EventQueue.java:682)[:1.7.0_07]
    at java.awt.EventQueue$3.run(EventQueue.java:680)[:1.7.0_07]
    at java.security.AccessController.doPrivileged(Native Method)[:1.7.0_07]
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)[:1.7.0_07]
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)[:1.7.0_07]
    at java.awt.EventQueue$4.run(EventQueue.java:696)[:1.7.0_07]
    at java.awt.EventQueue$4.run(EventQueue.java:694)[:1.7.0_07]
    at java.security.AccessController.doPrivileged(Native Method)[:1.7.0_07]
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)[:1.7.0_07]
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)[:1.7.0_07]
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)[:1.7.0_07]
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)[:1.7.0_07]
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:155)[:1.7.0_07]
    at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:182)[:1.7.0_07]
    at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:221)[:1.7.0_07]
    at java.security.AccessController.doPrivileged(Native Method)[:1.7.0_07]
    at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:219)[:1.7.0_07]
    at java.awt.Dialog.show(Dialog.java:1077)[:1.7.0_07]
    at java.awt.Component.show(Component.java:1651)[:1.7.0_07]
    at java.awt.Component.setVisible(Component.java:1603)[:1.7.0_07]
    at java.awt.Window.setVisible(Window.java:1014)[:1.7.0_07]
    at java.awt.Dialog.setVisible(Dialog.java:1003)[:1.7.0_07]
    at java_awt_Dialog$setVisible.call(Unknown Source)
    at org.xxxxxxx.views.core.impl.WorkbenchImpl$_showViewAsDialog_closure1.doCall(WorkbenchImpl.groovy:381)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_07]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_07]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_07]
    at java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_07]
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:226)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:52)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
    at org.xxxxxxx.views.core.impl.WorkbenchImpl$_showViewAsDialog_closure1.doCall(WorkbenchImpl.groovy)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_07]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_07]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_07]
    at java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_07]
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1047)
    at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:877)
    at groovy.lang.Closure.call(Closure.java:412)[68:groovy-all:1.8.6]
    at groovy.lang.Closure.call(Closure.java:406)[68:groovy-all:1.8.6]
    at groovy.lang.Closure.run(Closure.java:490)[68:groovy-all:1.8.6]
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:241)[:1.7.0_07]
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)[:1.7.0_07]
    at java.awt.EventQueue.access$200(EventQueue.java:103)[:1.7.0_07]
    at java.awt.EventQueue$3.run(EventQueue.java:682)[:1.7.0_07]
    at java.awt.EventQueue$3.run(EventQueue.java:680)[:1.7.0_07]
    at java.security.AccessController.doPrivileged(Native Method)[:1.7.0_07]
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)[:1.7.0_07]
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:691)[:1.7.0_07]
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)[:1.7.0_07]
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)[:1.7.0_07]
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)[:1.7.0_07]
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)[:1.7.0_07]
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)[:1.7.0_07]
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)[:1.7.0_07]
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
    at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:98)
    at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:157)
    at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142)
    at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:476)
    at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:343)
    ... 118 more
Caused by: org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/wsdl/soap/ registered.
    at org.apache.cxf.bus.managers.BindingFactoryManagerImpl.getBindingFactory(BindingFactoryManagerImpl.java:123)
    at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:116)
    at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91)
    ... 122 more

历史悠久,http://schemas.xmlsoap.org/wsdl/soap/ 的绑定工厂不可用。

使用 JUnit 和 Karaf 启动的区别在于,在 Spring 存在时,SpringBeanLocator 是实例化的,因此它会从 BindingFactoryManager 中删除 SoapBindingFactory 扩展,因此当它被请求时,它不存在。

我在src/main/resources/META-INF/spring/文件夹下也有conf.xml,内容如下:

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd">

    <import resource="classpath*:META-INF/cxf/cxf.xml"/>
    <import resource="classpath*:META-INF/cxf/cxf-extension-soap.xml"/>
    <import resource="classpath*:META-INF/cxf/cxf-servlet.xml"/>

</beans>

我使用的唯一依赖项是:

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-frontend-jaxws</artifactId>
    <version>2.7.8</version>
</dependency>

这也带来了这些:

\- org.apache.cxf:cxf-rt-frontend-jaxws:jar:2.7.8:compile
[INFO] |     +- xml-resolver:xml-resolver:jar:1.2:compile
[INFO] |     +- asm:asm:jar:3.3.1:compile
[INFO] |     +- org.apache.cxf:cxf-api:jar:2.7.8:compile
[INFO] |     |  +- org.codehaus.woodstox:woodstox-core-asl:jar:4.2.0:compile
[INFO] |     |  |  \- org.codehaus.woodstox:stax2-api:jar:3.1.1:compile
[INFO] |     |  +- org.apache.ws.xmlschema:xmlschema-core:jar:2.0.3:compile
[INFO] |     |  +- org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.7.1:compile
[INFO] |     |  \- wsdl4j:wsdl4j:jar:1.6.3:compile
[INFO] |     +- org.apache.cxf:cxf-rt-core:jar:2.7.8:compile
[INFO] |     |  \- com.sun.xml.bind:jaxb-impl:jar:2.2.6:compile
[INFO] |     +- org.apache.cxf:cxf-rt-bindings-soap:jar:2.7.8:compile
[INFO] |     |  \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:2.7.8:compile
[INFO] |     +- org.apache.cxf:cxf-rt-bindings-xml:jar:2.7.8:compile
[INFO] |     +- org.apache.cxf:cxf-rt-frontend-simple:jar:2.7.8:compile
[INFO] |     +- org.apache.cxf:cxf-rt-transports-http:jar:2.7.8:compile
[INFO] |     \- org.apache.cxf:cxf-rt-ws-addr:jar:2.7.8:compile
[INFO] |        \- org.apache.cxf:cxf-rt-ws-policy:jar:2.7.8:compile
[INFO] |           \- org.apache.neethi:neethi:jar:3.0.2:compile

是否可以停用“SpringBeanLocator”以使其不会从管理器中删除绑定工厂,或者正确配置它以使其实际工作?

【问题讨论】:

    标签: java spring jax-ws cxf apache-karaf


    【解决方案1】:

    为什么您需要为 WS 客户端使用 CXF? CXF 是重量级的工具,依赖很多,会干扰你的应用依赖树并导致问题,它更适合服务器端。

    对于客户端,我建议您不要使用任何特殊库。对于存根生成,可以使用来自 JDK 的 wsimport shell 命令(或相应的 maven 插件)。您必须使用的唯一依赖项是:

        <dependency>
            <groupId>com.sun.xml</groupId>
            <artifactId>com.springsource.com.sun.xml.messaging.saaj</artifactId>
            <version>${saaj.version}</version>
        </dependency>
    

    您需要做的另一件事是引导 com.sun.xml.internal.ws.client 包,而 karaf 的系统包通常不提供该包。

    【讨论】:

      猜你喜欢
      • 2017-01-19
      • 2017-08-17
      • 2017-08-20
      • 2013-11-11
      • 2017-07-25
      • 1970-01-01
      • 2017-11-14
      • 1970-01-01
      • 2018-01-05
      相关资源
      最近更新 更多