Uploaded image for project: 'OpenEJB'
  1. OpenEJB
  2. OPENEJB-997

context.xml is ignored

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 4.7.0
    • (not version related)
    • 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
      )

      { standardContext.addLifecycleListener(this); this.context = standardContext; boolean tmpOverride = standardContext.getOverride(); standardContext.setOverride(true); this.contextConfig(); standardContext.setOverride(tmpOverride); }

      public static void initContext(
      StandardContext standardContext
      )

      { WebAppContextConfig config = new WebAppContextConfig(); config.init(standardContext); }

      }

      Of course this is far from a clean solution. Any comments?

      Attachments

        1. tomcat.diff
          1 kB
          Jonathan Gallimore

        Activity

          People

            jgallimore Jonathan Gallimore
            jgallimore Jonathan Gallimore
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: