contextHandler. setHandler ( resourceHandler ) ;

// There's an undocumented quirk in Jetty: ServletContextHandler always answers 404 when it cannot

// find a resource, without giving a chance to other handlers to try and find it.

// The workaround is making sure the ServletContextHandler is the LAST element in the handlerCollection,

// so that the various ResourceHandlers can try and find their resources, and delegate to the

// ServletContextHandler if they cannot find it.

// That's why this code removes and adds again. Oh, and after adding they have to be started again.

handlerCollection. removeHandler ( servletContextHandler ) ;

handlerCollection. addHandler ( contextHandler ) ;

handlerCollection. addHandler ( servletContextHandler ) ;

resourceHandler. start ( ) ;

contextHandler. start ( ) ;