使用CXF JaxWsServerFactoryBean异常无法从总线中找到任何已注册的HttpDestinationFactory

时间:2012-11-29 02:02:55

标签: 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(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">

6 个答案:

答案 0 :(得分:75)

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

答案 1 :(得分:5)

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

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

解决方案是简单地提及没有附加http / https到地址的相对网址。

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

答案 2 :(得分: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" />

答案 3 :(得分:3)

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

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

答案 4 :(得分:1)

尝试以下方法,它对我有用-

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

答案 5 :(得分:0)

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

<div id="img-div">
  <div id="overlay-div"></div>
</div>
相关问题