Problem moving to Jetty 7

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Problem moving to Jetty 7

A few inconsistencies with porting from Jetty 6 to Jetty 7: Using Jetty 7.0.0.RC0

We have an inhouse build server based on Jetty which supports adding multiple WebAppContext's.
Usually with Jetty 6 we would call server.addhandler(webAppContext) to add the WebAppContext after we construct it, but that option has now been removed from Jetty 7.

After digging around in some examples in the org.eclipse.jetty maven repository I came up with the following revision to the code

Constructor adding an ContextHandlerCollection to the server and adding an PingHandler to the ContextHandlerCollection.
public void WebServer(){
  ContextHandlerCollection contexts = new ContextHandlerCollection();
  ContextHandler contextHandler = new ContextHandler();
  pingHandler = new PingHandler();

This method adds a new WebApplication to the server
private WebAppContext addWebApplication(String contextPath, String webApp) {
  Handler handler = server.getHandler();
  if(handler instanceof ContextHandlerCollection){ //As it obviously is, as it has been set in   constructor, but I check anyway.
        ContextHandlerCollection handlerCollection = (ContextHandlerCollection) handler;

Is this the correct method of adding a WebAppContext handler to the server instead of the old server.addHandler?

One other thing:
        Connector[] connectors = this.server.getConnectors();
        for (Connector connector : connectors) {
revision for Jetty 7
        Connector[] connectors = this.server.getConnectors();
        for (Connector connector : connectors) {
When I run this new solution with Jetty 7 I get an error stating that:
java.lang.IllegalStateException: No processor for web xml

I can not find any information for use of the WebXmlProcessor in this situation.

One last thing:

Jetty seriously needs a reference guide like the one Hibernate and Spring got. Jetty 7 has major restructuring which one needs to read the source code to find out about.