繁体   English   中英

在Spring的Karaf上使用Apache CXF不存在SoapBindingFactory

[英]SoapBindingFactory not present using Apache CXF on Karaf with Spring

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

该应用程序在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'从而不会从管理器中删除绑定工厂,还是对其进行正确配置以使其真正起作用?

为什么需要为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系统捆绑包通常不提供该软件包。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM