Uploaded image for project: 'JBoss Web Server'
  1. JBoss Web Server
  2. JWS-1000

Add system property expansion support for properties files

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Critical
    • JWS 5.0_RHEL DR2
    • JWS 3.1.0 SP2 DR2
    • tomcat
    • None
    • Documentation (Ref Guide, User Guide, etc.), User Experience

    Description

      Add system property expansion support for properties files.

      JWS-847 added a new system property org.apache.tomcat.util.digester.REPLACE_SYSTEM_PROPERTIES to allow system property value replacement from the digester property source. However, Digester.replaceProperties() invokes only one property source which is specified with org.apache.tomcat.util.digester.PROPERTY_SOURCE.
      Hence, even if org.apache.tomcat.util.digester.REPLACE_SYSTEM_PROPERTIES is set to true, the Digester.replaceProperties() does not invoke Digester$SystemPropertySource, so system property expansion does not happen for properties files.

      Also note that JWS-863 added a support for multiple properties files. We need to support hierarchical reference of variables within these multiple properties files.

      LoadExternalPropertiesListener invokes Digester.replaceProperties() after loading properties files when org.apache.tomcat.util.digester.REPLACE_SYSTEM_PROPERTIES is set to true. So, both requirements can be achieved if we fix Digester.replaceProperties() to invoke Digester$SystemPropertySource.

      ---------

      Steps to reproduce the issue.

      1. Configure the following in server.xml:

      <Listener className="org.apache.catalina.core.LoadExternalPropertiesListener
         file.0="${catalina.base}/conf/test0.properties"
         file.1="${catalina.base}/conf/test1.properties"
         overwrite="true" loadFirst="true"/>
      
      ...
      
          <Connector port="${tomcat.http.port}" protocol="HTTP/1.1"
                     connectionTimeout="20000"
                     redirectPort="8443" />
      
          <Connector port="${tomcat.ajp.port}" protocol="AJP/1.3" redirectPort="8443" />
      

      2. Add the following to conf/catalina.properties:

      org.apache.tomcat.util.digester.REPLACE_SYSTEM_PROPERTIES=true
      my.http.port=8080
      

      3. Add the following to conf/test0.properties:

      my.ajp.port=8009
      

      4. Add the following to conf/test1.properties:

      tomcat.http.port=${my.http.port}
      tomcat.ajp.port=${my.ajp.port}
      

      5. Start tomcat then you will see the following exception at start-up:

      SEVERE [main] org.apache.catalina.core.StandardService.startInternal Failed to start connector [Connector[HTTP/1.1-auto-1]]
       org.apache.catalina.LifecycleException: Failed to start component [Connector[HTTP/1.1-auto-1]]
      	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
      	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:459)
      	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
      	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:789)
      	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
      	at org.apache.catalina.startup.Catalina.start(Catalina.java:629)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:349)
      	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:483)
      Caused by: org.apache.catalina.LifecycleException: The connector cannot start since the specified port value of [-1] is invalid
      	at org.apache.catalina.connector.Connector.startInternal(Connector.java:979)
      	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
      	... 11 more
      
      SEVERE [main] org.apache.catalina.core.StandardService.startInternal Failed to start connector [Connector[AJP/1.3-auto-2]]
       org.apache.catalina.LifecycleException: Failed to start component [Connector[AJP/1.3-auto-2]]
      	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
      	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:459)
      	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
      	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:789)
      	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
      	at org.apache.catalina.startup.Catalina.start(Catalina.java:629)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:349)
      	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:483)
      Caused by: org.apache.catalina.LifecycleException: The connector cannot start since the specified port value of [-1] is invalid
      	at org.apache.catalina.connector.Connector.startInternal(Connector.java:979)
      	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
      	... 11 more
      

      Attachments

        Issue Links

          Activity

            People

              rhn-support-csutherl Coty Sutherland
              rhn-support-mmiura Masafumi Miura
              Matus Madzin Matus Madzin
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: