title: CXF jaxws endpoint relative publish address
body: <p>I am having a lot of difficulty trying to use a relative publish address in my CXF web service endpoint configuration. </p>
  
  <p>I have a simple Java-first JAX-WS project with the following configuration files:</p>
  
  <p>applicationContent-cxf.xml:</p>
  
  <pre><code>&lt;beans xmlns=...&gt;
      ...
      &lt;jaxws:endpoint
          id="helloWorldService"
          implementorClass="org.helloworld.ws.HelloWorldServiceImpl"
          implementor="#helloWorldServiceImpl" &lt;!-- spring managed --&gt;
          endpointName="sayHello"
          address="HelloWorldService"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>web.xml:</p>
  
  <pre><code>&lt;web-app&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;
              WEB-INF/applicationContext.xml
              WEB-INF/applicationContext-cxf.xml
          &lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;listener&gt;
          &lt;listener-class&gt;
              org.springframework.web.context.ContextLoaderListener
          &lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;HelloWorldServlet&lt;/servlet-name&gt;
          &lt;display-name&gt;Hello World Servlet&lt;/display-name&gt;
          &lt;servlet-class&gt;
              org.apache.cxf.transport.servlet.CXFServlet
          &lt;/servlet-class&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;HelloWorldServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/services/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>According to <a href="http://cxf.apache.org/docs/servlet-transport.html">http://cxf.apache.org/docs/servlet-transport.html</a>, it seems i should be able to specify the publish address of <code>HelloWorldService</code> and the URL of the service will resolve to (e.g.) <a href="http://localhost:8080/services/HelloWorldService">http://localhost:8080/services/HelloWorldService</a>. But when I try to go to <a href="http://localhost:8080/services/HelloWorldService?wsdl">http://localhost:8080/services/HelloWorldService?wsdl</a> I get a 404. If i change the publish address in my jaxws endpoint to the absolute URL <code>http://localhost:8080/services/HelloWorldService</code> I am able to access the wsdl.</p>
  
  <p>I want to specify a relative endpoint address if possible. I am new to using CXF (and writing web services), so any help is much appreciated!</p>
  
  <p><strong>UPDATE 1:</strong></p>
  
  <p>Note that I am deploying my web service to Tomcat 7. I don't know what is logging it, but one of the lines in my start up log states <code>Setting the server's publish address to be HelloWorldService</code>. If anyone needs more info to help me please let me know.</p>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>It appears that CXF detects whether a CXFServlet is "being used" and uses an embedded jetty instance if it is not. <a href="http://cxf.apache.org/docs/xfire-migration-guide.html#XFireMigrationGuide-HTTPandServletSetup">http://cxf.apache.org/docs/xfire-migration-guide.html#XFireMigrationGuide-HTTPandServletSetup</a>. So, for some reason CXF is using the embedded jetty instance instead of my servlet. However, I don't know what further configuration I need besides the HelloWorldServlet in my web.xml, and the CXF documentation doesn't help me further.</p>