Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
4.7.0
-
None
-
None
Description
Hi,
I have a similar problem with TomcatWebAppBuilder which is related to
user-defined contexts:
In the method
public void deployWebApps(AppInfo appInfo, ClassLoader classLoader);
the standardContext is initialized as follows:
if (getContextInfo(webApp) == null) {
StandardContext standardContext = new StandardContext();
standardContext.addLifecycleListener(new ContextConfig());
standardContext.setPath("/" + webApp.contextRoot);
standardContext.setDocBase(webApp.codebase);
standardContext.setParentClassLoader(classLoader);
standardContext.setDelegate(true);
The problem in my opinion is the line
standardContext.addLifecycleListener(new ContextConfig());
i.e. the standardContext is initialized with an empty ContextConfig. If a
context.xml is defined for a WebApp (located in one of the standard places,
conf/Catalina/<host>/, META-INF/context.xml, ...) it is ignored. This is
very undesirable if a context.xml defines Resources, ...
With the following hack the ContextConfig is initialized with
META-INF/context.xml:
StandardContext standardContext = new StandardContext();
standardContext.setConfigFile(
webApp.codebase + "/META-INF/context.xml"
);
WebAppContextConfig.initContext(standardContext);
standardContext.setPath("/" + webApp.contextRoot);
standardContext.setDocBase(webApp.codebase);
standardContext.setParentClassLoader(classLoader);
standardContext.setDelegate(true);
and the helper class
private static class WebAppContextConfig extends ContextConfig {
private void init(
StandardContext standardContext
)
public static void initContext(
StandardContext standardContext
)
}
Of course this is far from a clean solution. Any comments?