Uploaded image for project: 'Apache Tomcat Maven Plugin'
  1. Apache Tomcat Maven Plugin
  2. MTOMCAT-281

It is impossible to override 9 system properties that are packed within totomcat-embed-core-7.0.47.jar!/org/apache/catalina/startup/catalina.properties

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.2
    • Fix Version/s: None
    • Component/s: tomcat7
    • Labels:
      None
    • Environment:
      all

      Description

      It is impossible to override following properties

      • package.access
      • package.definition
      • common.loader
      • server.loader
      • shared.loader
      • tomcat.util.scan.DefaultJarScanner.jarsToSkip
      • org.apache.catalina.startup.ContextConfig.jarsToSkip
      • org.apache.catalina.startup.TldConfig.jarsToSkip
      • tomcat.util.buf.StringCache.byte.enabled
        from tomcat7 maven plugin configuration.

      The reason is that code in org.apache.catalina.startup.CatalinaProperties#loadProperties() blindly overrides all system properties with properties from totomcat-embed-core-7.0.47.jar!/org/apache/catalina/startup/catalina.properties by default. As a result following tomcat7 maven plugin configuration is not used:

      <systemProperties>
             <org.apache.catalina.startup.ContextConfig.jarsToSkip>my-other-jar-to-skip.jar</org.apache.catalina.startup.ContextConfig.jarsToSkip>
      </systemProperties>

      which is a convenient way to adjust startup performance of Tomcat (which is poor due to Servlet Spec 3.0 requirements to scan all classes).

      I suggest either

      • to call org.apache.tomcat.maven.plugin.tomcat7.run.AbstractRunMojo#setupSystemProperties() (which applies system properties from maven plugin configuration) after org.apache.catalina.startup.CatalinaProperties.getProperty() (which applies system properties from tomcat embedded catalina.properties file) in method org.apache.tomcat.maven.plugin.tomcat7.run.AbstractRunMojo#startContainer() and not the other way around; or
      • to modify org.apache.catalina.startup.CatalinaProperties#loadProperties() and to check whether a particular System property already exists

      There is also a workaround which prevents the embedded Tomcat from loading the default catalina.properties file:

      <systemProperties>
               <catalina.config>${project.baseUri}/target/tomcat/logs</catalina.config>
               <!-- or use any other path which results in an empty set of properties -->
      </systemProperties>
      

      In such case, system properties specified from command line or maven plugin configuration are used.

      If desired, I can provide you with a pull request or a patch in order to make it more easy for you.

      Thanks,
      Stepan

        Attachments

          Activity

            People

            • Assignee:
              olamy Olivier Lamy
              Reporter:
              stepanv Stepan Vavra
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: