*/
protected ClassLoader createClassLoader()
throws Exception {
Class<?> clazz = Class.forName(loaderClass);
WebappClassLoader classLoader = null;
if (parentClassLoader == null) {
parentClassLoader = Thread.currentThread().getContextClassLoader();
}
Class<?>[] argTypes = { ClassLoader.class };
Object[] args = { parentClassLoader };
Constructor<?> constr = clazz.getConstructor(argTypes);
classLoader = (WebappClassLoader) constr.newInstance(args);
classLoader.setUseMyFaces(useMyFaces);
/*
* Start the WebappClassLoader here as opposed to in the course of
* WebappLoader#start, in order to prevent it from being started
* twice (during normal deployment, the WebappClassLoader is created
* by the deployment backend without calling
* WebappLoader#createClassLoader, and will have been started
* by the time WebappLoader#start is called)
*/
try {
classLoader.start();
} catch (Exception e) {
throw new LifecycleException(e);
}
return classLoader;