使用CXF JaxWsServerFactoryBeanexception从总线中找不到任何已注册的HttpDestinationFactory
在控制台模式下使用Apache CXF JaxWsServerFactoryBean(尝试通过java命令行启动服务器)将得到如下的exception:
Caused by: java.io.IOException: Cannot find any registered HttpDestinationFactory from the Bus. at org.apache.cxf.transport.http.HTTPTransportFactory.getDestination(HTTPTransportFactory.java:295) at org.apache.cxf.binding.soap.SoapTransportFactory.getDestination(SoapTransportFactory.java:143) at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:93) at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:72) at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:160)
当通过Spring在Tomcat中使用相同的服务impl时,它将起作用。
<jaxws:endpoint id="abc" implementor="com.AbcServicePortTypeImpl" address="/abc">
在maven pom.xml中包含cxf-rt-transports-http-jetty jar将会解决这个问题。
<dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http-jetty</artifactId> <version>2.7.6</version> </dependency>
例如,如果您具有以下configuration,并且地址是使用http定义的,而不是与configuration的CXFServlet相关的URL,则会出现上述错误。
<jaxrs:server id="helloRestService" address="http://..."> <jaxrs:serviceBeans> <ref bean="helloService" /> </jaxrs:serviceBeans> </jaxrs:server>
解决方法是简单地提到没有http / https附加地址的相对url。
我有同样的问题。 没有一个谷歌的东西是有道理的。 我发现在我的情况下,我在spring的上下文文件中缺less以下内容:
<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" />
另一个与CSV 2.7.15协同工作的解决scheme:在创buildBus
,注册一个扩展名:
ServletDestinationFactory destinationFactory = new ServletDestinationFactory(); bus.setExtension(destinationFactory, HttpDestinationFactory.class);