title: Spring, Apache CXF and Embedded Jetty
body: <p>I'm trying create a web service capable server using Apache CXF, Spring and an embedded Jetty server. When I run my project the server seems to initialize correctly, however when I navigate to <a href="http://localhost:8080/SomeService" rel="nofollow">http://localhost:8080/SomeService</a> expecting to see the service WSDL, instead I get the following exception:</p>
  
  <pre><code>SEVERE: /SomeService
  java.lang.NullPointerException
      at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:163)
      at org.apache.cxf.transport.servlet.AbstractCXFServlet.doGet(AbstractCXFServlet.java:145)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
      at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.Server.handle(Server.java:324)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
      at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
      at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
      at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>Here's the Java main()</p>
  
  <pre><code>public static void main(String[] args) throws Exception {                    
      new ClassPathXmlApplicationContext(new String[] {"beans-jetty.xml"});
  }
  </code></pre>
  
  <p>beans-jetty.xml</p>
  
  <pre><code>&lt;bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
      &lt;property name="location" value="file:conf/server.properties" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="server"
        class="org.mortbay.jetty.Server"
        init-method="start"
        destroy-method="stop"&gt;
      &lt;property name="connectors"&gt;
          &lt;list&gt;
              &lt;bean id="connector" class="org.mortbay.jetty.nio.SelectChannelConnector"&gt;
                  &lt;property name="host" value="${server.address}"/&gt;
                  &lt;property name="port" value="${server.port}"/&gt;
              &lt;/bean&gt;
          &lt;/list&gt;
      &lt;/property&gt;
      &lt;property name="handlers"&gt;
          &lt;list&gt;
              &lt;ref bean="context-cxf"/&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean name="context-cxf" class="org.mortbay.jetty.servlet.Context"&gt;
      &lt;property name="contextPath" value="/" /&gt;
      &lt;property name="handler"&gt;
          &lt;bean class="org.mortbay.jetty.servlet.ServletHandler"&gt;
              &lt;property name="servlets"&gt;
                  &lt;list&gt;
                      &lt;bean class="org.mortbay.jetty.servlet.ServletHolder"&gt;
                          &lt;property name="name" value="cxf-servlet-holder" /&gt;
                          &lt;property name="servlet"&gt;
                              &lt;bean class="org.apache.cxf.transport.servlet.CXFServlet" /&gt;
                          &lt;/property&gt;
                      &lt;/bean&gt;
                  &lt;/list&gt;
              &lt;/property&gt;
              &lt;property name="servletMappings"&gt;
                  &lt;list&gt;
                      &lt;bean class="org.mortbay.jetty.servlet.ServletMapping"&gt;
                          &lt;property name="servletName" value="cxf-servlet-holder" /&gt;
                          &lt;property name="pathSpec" value="/*" /&gt;
                      &lt;/bean&gt;
                  &lt;/list&gt;
              &lt;/property&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;import resource="classpath:META-INF/cxf/cxf-servlet.xml" /&gt;
  &lt;import resource="classpath:/beans-cxf.xml" /&gt;
  </code></pre>
  
  <p>beans-cxf.xml</p>
  
  <pre><code>&lt;import resource="classpath:META-INF/cxf/cxf.xml" /&gt;
  &lt;import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /&gt;
  
  &lt;jaxws:endpoint
          id="someService"
          implementor="com.awebster.gitta.services.SomeServiceImpl"
          address="${server.address}" /&gt;
  </code></pre>
  
  <p>I should mention that I'm using the Maven one-jar plugin, although I doubt that makes any difference to this problem.</p>
  
  <p>Many Thanks in advance!</p>
  
  <p>Anthony</p>