java.io.IOException: Cannot find any registered HttpDestinationFactory from the Bus.

来源:互联网 发布:马踏棋盘贪心算法 编辑:程序博客网 时间:2024/05/18 01:20

异常信息:

Exception in thread "main" org.apache.cxf.service.factory.ServiceConstructionException    at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:217)    at com.lesson.background.JettyService.main(JettyService.java:23)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    at java.lang.reflect.Method.invoke(Method.java:497)    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)Caused by: java.io.IOException: Cannot find any registered HttpDestinationFactory from the Bus.    at org.apache.cxf.transport.http.HTTPTransportFactory.getDestination(HTTPTransportFactory.java:269)[org.apache.cxf.transport.http.HTTPTransportFactory] - Cannot find any registered HttpDestinationFactory from the Bus.    at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:84)    at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:63)    at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:170)    ... 6 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的实现。

解决办法:


在pom.xml文件中添加:

<dependency>    <groupId>org.apache.cxf</groupId>    <artifactId>cxf-rt-transports-http-jetty</artifactId>    <version>3.1.6</version></dependency>
2 0
原创粉丝点击