private void doTestDispatchError(int iter, boolean useThread,
boolean completeOnError)
throws Exception {
resetTracker();
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
File docBase = new File(System.getProperty("java.io.tmpdir"));
Context ctx = tomcat.addContext("", docBase.getAbsolutePath());
DispatchingServlet dispatch =
new DispatchingServlet(true, completeOnError);
Wrapper wrapper = Tomcat.addServlet(ctx, "dispatch", dispatch);
wrapper.setAsyncSupported(true);
ctx.addServletMapping("/stage1", "dispatch");
ErrorServlet error = new ErrorServlet();
Tomcat.addServlet(ctx, "error", error);
ctx.addServletMapping("/stage2", "error");
ctx.addApplicationListener(TrackingRequestListener.class.getName());
TesterAccessLogValve alv = new TesterAccessLogValve();
ctx.getPipeline().addValve(alv);
tomcat.start();
StringBuilder url = new StringBuilder(48);
url.append("http://localhost:");
url.append(getPort());
url.append("/stage1?iter=");