49

在控制台模式下使用 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)

当通过 Spring 在 Tomcat 中使用相同的服务 impl 时,它可以工作。

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

6 回答 6

84

在 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>
于 2013-08-16T06:43:49.207 回答
8

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

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

解决方案是简单地提及不附加 http/https 的相对 url 地址。

http://grokbase.com/t/camel/users/155f1smn4v/error-cannot-find-any-registered-httpdestinationfactory-from-the-bus

于 2016-03-27T02:35:09.027 回答
3

我有同样的问题。谷歌的东西都没有意义。我发现在我的情况下我在 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" />
于 2013-06-07T18:19:23.350 回答
3

另一个适用于 CSV 2.7.15 的解决方案:当您创建 时Bus,注册一个扩展:

ServletDestinationFactory destinationFactory = new ServletDestinationFactory();
bus.setExtension(destinationFactory, HttpDestinationFactory.class);
于 2016-01-15T09:32:06.300 回答
2

尝试以下,它对我有用 -

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-transports-http-jetty</artifactId>
    <version>3.2.5</version>
    <exclusions>
        <exclusion>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-util</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-io</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-security</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-continuation</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-http</artifactId>
        </exclusion>
    </exclusions>
</dependency>
于 2018-08-12T16:51:20.890 回答
0

将 CAMEL-CXF 与 REST 服务一起使用时,我遇到了同样的错误。我通过骆驼路由和bean xml文件配置了端点,并且都给出了错误。我使用的是骆驼版本 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>
于 2021-05-20T15:04:54.160 回答