51

When use Apache CXF JaxWsServerFactoryBean in console mode (try to start the server by java command line) Will get exception like below:

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)

When same service impl used in Tomcat via Spring, it works.

<jaxws:endpoint id="abc" implementor="com.AbcServicePortTypeImpl" address="/abc">
Anderson Mao
  • 1,101
  • 1
  • 9
  • 7
  • 12
    Solved by add jetty dependency jars: (from 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, ---- Note: geronimo-servlet_3.0_spec-1.0.jar is required otherwise will get "connection refused" exception in client. – Anderson Mao Nov 29 '12 at 02:04
  • 1
    I would have upvoted this as an answer! Thanks – ThanksForAllTheFish Feb 07 '13 at 13:13
  • I had this same issue. I found the answer [here](http://mail-archives.apache.org/mod_mbox/camel-users/201505.mbox/%3CetPan.55641cf2.327b23c6.1c1@localhost%3E)! As said, if you have added some ambedded server (jetty, netty, ...), you need to add the jars on the classpath. That is how I coorected it. :) –  Mar 05 '20 at 00:19

6 Answers6

86

Include cxf-rt-transports-http-jetty jar in the maven pom.xml will solve the problem.

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http-jetty</artifactId>
        <version>2.7.6</version>
    </dependency>
sendon1982
  • 9,982
  • 61
  • 44
7

For example, if you have below configuration and the address is defined with http appended to it, which is not a relative url to the CXFServlet configured, the above error will come.

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

Solution is to simply mention the relative url without http/https appended to address.

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

5

Another solution which works with CSV 2.7.15: when you create the Bus, register an extension:

ServletDestinationFactory destinationFactory = new ServletDestinationFactory();
bus.setExtension(destinationFactory, HttpDestinationFactory.class);
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
3

I had the same problem. And none of the google stuff was making sense. I found out in my case that I was missing the following in the spring context file:

   <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" />
Ashesh Vidyut
  • 119
  • 2
  • 9
2

Try the following, it worked for me -

<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>
Prateek Mehta
  • 488
  • 1
  • 8
  • 15
0

I got the same error when using CAMEL-CXF with REST service. I configured the endpoint via both camel route and beans xml file and both were giving the error. I am using camel version 2.14.1 so adding following dependencies worked for me.

  <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>
user0904
  • 210
  • 3
  • 7