This wasn't easy to thing to accomplish. It took few hours of hard work to find the required information from jetty's source code.
Here's the solution that worked with my simple test application that threw ServletException on HttpServlet init method. The key to the success is to set ServletHandler's startWithUnavailable property to false.
pom.xml:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.10.v20130312</version>
<configuration>
<contextXml>src/main/resources/context.xml</contextXml>
<webAppConfig>
<throwUnavailableOnStartupException>true</throwUnavailableOnStartupException>
</webAppConfig>
</configuration>
</plugin>
context.xml:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure>
<Set name="throwUnavailableOnStartupException">true</Set>
<Set name="servletHandler">
<New class="org.eclipse.jetty.servlet.ServletHandler">
<Set name="startWithUnavailable">false</Set>
</New>
</Set>
</Configure>
TestServlet.java:
public class TestServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
public void init() throws ServletException {
super.init();
throw new ServletException("FAIL!");
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
}
}