Hi

I did some work to fix get the test work.
I had no luck with fixing the jetty-beans.xml, so I wrote some java code to start the jetty server like this. You need to make sure the servlet is using the same bus with the jaxws endpoint that you publish thought the spring config.

public class WebServer {

    public static void main(String[] args) throws Exception {
        Server server = new Server(8080);

ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
        context.setContextPath("/");
        server.setHandler(context);
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(WebServer.class.getResource("/cxf-beans.xml").toExternalForm());

        CXFNonSpringServlet servlet = new CXFNonSpringServlet();
        // Wire the bus that endpoint uses with the Servlet
        servlet.setBus((Bus)applicationContext.getBean("cxf"));

        context.addServlet(new ServletHolder(servlet),"/cxf/services/*");
        server.start();
        server.join();
    }


}
On 6/14/11 1:43 AM, Anthony Webster wrote:
Hello,

I'm trying to run webservices and servlets on an embedded Jetty server via
CXF and using Spring. Under CXF 2.2.3 I kept getting NulPointerExceptions
when trying to access my services. After some searching I found the
following JIRA issue (
https://issues.apache.org/jira/browse/CXF-3001?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel)
which states that the problem lies with Jetty6. So I upgrading to CXF 2.4
which uses a Jetty 7.3. I also changed my jetty-beans to suit Jetty7
according to the spring config files attached to the JIRA issue. This gave
rise to the following exception :

MultiException[java.lang.ClassCastException:
org.eclipse.jetty.server.handler.ContextHandler cannot be cast to
org.eclipse.jetty.servlet.ServletContextHandler,
java.lang.ClassCastException:
org.eclipse.jetty.server.handler.ContextHandler cannot be cast to
org.eclipse.jetty.servlet.ServletContextHandler]
  at
org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:186)...

So I changed the ContextHandlers to ServletContextHandler
from org.eclipse.jetty.servlet (not included in CXF so I used the same Jetty
version i.e. 7.3.1.v20110307).

Now the server launches fine but I get 404s whenever I try to access
anything! Plus my traces in the servlets show that they aren't being
initialized at all.

Any help would be most appreciated!

Anthony

PS. I'll dump the whole project (small) online at some point...



--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang

Reply via email to