转自:http://iteye.blog.163.com/blog/static/186308096201210265553996/
严重: Cannot find any registered HttpDestinationFactory from the Bus解决方案
一、控制台异常信息:
- 严重: Cannot find any registered HttpDestinationFactory from the Bus.
- Exception in thread "main" javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
- at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:350)
- at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:239)
- at org.apache.cxf.jaxws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:144)
- at javax.xml.ws.Endpoint.publish(Endpoint.java:170)
- at demo.hw.server.Server.<init>(Server.java:31)
- at demo.hw.server.Server.main(Server.java:36)
- Caused by: org.apache.cxf.service.factory.ServiceConstructionException
- at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:176)
- at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:203)
- at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:433)
- at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:322)
- ... 5 more
- Caused by: java.io.IOException: Cannot find any registered HttpDestinationFactory from the Bus.
- at org.apache.cxf.transport.http.HTTPTransportFactory.getDestination(HTTPTransportFactory.java:270)
- at org.apache.cxf.binding.soap.SoapTransportFactory.getDestination(SoapTransportFactory.java:136)
- 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:158)
- ... 8 more
二、解决方案:
在使用cxf过程中经常出 Cannot find any registered HttpDestinationFactory from the Bus,一般是没有引入cxf-rt-transports-http-jetty-xxx.jar。查看apache.cxf.transport.http.HTTPTransportFactory.getDestination(HTTPTransportFactory.java:270)类,jettyFactory为null,也就是缺少http-jetty的实现。如果部署到tomcat一般不会出现这个问题。
修改pom.xml
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>2.4.5-SNAPSHOT</version>
</dependency>
</dependencies>
为
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>2.4.6</version>
</dependency>
</dependencies>