Jax ws Use CXF JaxWsServerFactoryBean异常无法从总线中找到任何已注册的HttpDestinationFactory

Jax ws Use CXF JaxWsServerFactoryBean异常无法从总线中找到任何已注册的HttpDestinationFactory,jax-ws,cxf,Jax Ws,Cxf,在控制台模式下使用Apache CXF JaxWsServerFactoryBean时(尝试通过java命令行启动服务器) 将得到如下异常: Caused by: java.io.IOException: Cannot find any registered HttpDestinationFactory from the Bus. at org.apache.cxf.transport.http.HTTPTransportFactory.getDestination(HTTPTr

在控制台模式下使用Apache CXF JaxWsServerFactoryBean时(尝试通过java命令行启动服务器) 将得到如下异常:

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)
原因:java.io.IOException:无法从总线中找到任何已注册的HttpDestinationFactory。
位于org.apache.cxf.transport.http.HTTPTransportFactory.getDestination(HTTPTransportFactory.java:295)
位于org.apache.cxf.binding.soap.SoapTransportFactory.getDestination(SoapTransportFactory.java:143)
位于org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:93)
位于org.apache.cxf.endpoint.ServerImpl.(ServerImpl.java:72)
位于org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:160)
当通过Spring在Tomcat中使用相同的服务impl时,它可以工作

<jaxws:endpoint id="abc" implementor="com.AbcServicePortTypeImpl" address="/abc">

我也有同样的问题。谷歌的东西都没有意义。在我的案例中,我发现spring上下文文件中缺少以下内容:

   <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" />

在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>

org.apache.cxf
cxf rt传输http jetty
2.7.6

另一个使用CSV 2.7.15的解决方案:当您创建
总线时,注册一个扩展:

ServletDestinationFactory destinationFactory = new ServletDestinationFactory();
bus.setExtension(destinationFactory, HttpDestinationFactory.class);

例如,如果您有以下配置,并且该地址被定义为附加了http,而该地址不是配置的CXFServlet的相对url,则会出现上述错误

<jaxrs:server id="helloRestService" address="http://...">
        <jaxrs:serviceBeans>
            <ref bean="helloService" />
        </jaxrs:serviceBeans>
</jaxrs:server>

解决方案是只提及相对url,而不在地址中附加http/https

试试下面的方法,它对我很有效-


org.apache.cxf
cxf rt传输http jetty
3.2.5
org.eclipse.jetty
jetty服务器
org.eclipse.jetty
码头
org.eclipse.jetty
码头
org.eclipse.jetty
码头保安
org.eclipse.jetty
码头延伸
org.eclipse.jetty
jetty http

将CAMEL-CXF与REST服务一起使用时,我遇到了相同的错误。我通过camel路由和beans xml文件配置了端点,但都给出了错误。我使用的是camel版本2.14.1,因此添加以下依赖项对我来说很有用

  <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <version>4.5.1</version>
      <scope>test</scope>
  </dependency>

  <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-transports-http-jetty</artifactId>
      <version>3.0.3</version>
      <scope>test</scope>
  </dependency>

org.apache.httpcomponents
httpclient
4.5.1
测试
org.apache.cxf
cxf rt传输http jetty
3.0.3
测试

add jetty dependency jars解决:(来自apache-cxf-2.7.0.zip)cxf-rt-transports-http-jetty-2.7.0.jar,geronimo-servlet_3.0_spec-1.0.jar,jetty-*.jar,---注意:geronimo-servlet_3.0_spec-1.0.jar是必需的,否则将在客户端中出现“连接被拒绝”异常。我会对此进行投票!ThanksI也有同样的问题。我找到了答案!如上所述,如果您已经添加了一些嵌入式服务器(jetty、netty等等),那么您需要在类路径上添加JAR。我就是这样写的。:)如果只需要运行组件测试,通常在运行Servlet容器下运行应用程序时,请考虑添加测试。
  <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <version>4.5.1</version>
      <scope>test</scope>
  </dependency>

  <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-transports-http-jetty</artifactId>
      <version>3.0.3</version>
      <scope>test</scope>
  </dependency>