// save context classloader
Thread thread= Thread.currentThread();
ClassLoader lastContextLoader= thread.getContextClassLoader();
MultiException mex= null;
try
{
// Find the webapp
resolveWebApp();
// Get the handler
getServletHandler();
_configurations=loadConfigurations();
// initialize the classloader
configureClassPath();
initClassLoader(true);
thread.setContextClassLoader(getClassLoader());
initialize();
// Do the default configuration
configureDefaults();
// Set classpath for Jasper.
Map.Entry entry= _webAppHandler.getHolderEntry("test.jsp");
if (entry != null)
{
ServletHolder jspHolder= (ServletHolder)entry.getValue();
if (jspHolder != null && jspHolder.getInitParameter("classpath") == null)
{
String fileClassPath= getFileClassPath();
jspHolder.setInitParameter("classpath", fileClassPath);
if (log.isDebugEnabled())
log.debug("Set classpath=" + fileClassPath + " for " + jspHolder);
}
}
// configure webapp
configureWebApp();
// If we have servlets, don't init them yet
_webAppHandler.setAutoInitializeServlets(false);
// Start handlers
super.doStart();
mex= new MultiException();
// Context listeners
if (_contextListeners != null && _webAppHandler != null)
{
ServletContextEvent event= new ServletContextEvent(getServletContext());
for (int i= 0; i < LazyList.size(_contextListeners); i++)
{
try
{
((ServletContextListener)LazyList.get(_contextListeners, i)).contextInitialized(event);
}
catch (Exception ex)
{
mex.add(ex);
}
}
}
// OK to Initialize servlets now
if (_webAppHandler != null && _webAppHandler.isStarted())
{
try
{
_webAppHandler.initializeServlets();
}
catch (Exception ex)
{
mex.add(ex);
}
}
}
catch (Exception e)
{
log.warn("Configuration error on " + _war, e);
throw e;
}
finally
{
thread.setContextClassLoader(lastContextLoader);
}
if (mex != null)
mex.ifExceptionThrow();
}