Announcement Announcement Module
Collapse
No announcement yet.
Custom templates and properties processing problems Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom templates and properties processing problems

    I've tried to create custom template and found the problem, here is output:

    Code:
    [myapp@localhost tc-server]$ ./tcruntime-instance.sh create -i ~/instances myapp-instance1 --interactive --version 6.0.33.A.RELEASE -t myapp
    Creating instance 'myapp-instance1' ...
      Using separate layout
      Creating bin/setenv.sh
      Applying template 'base'
        Copying template's contents
          Please enter the user account that should start the instance when using the 'bin/init.d.sh' script. Default 'tc-server': myapp
        Applying fragment 'context-fragment.xml' to 'conf/context.xml'
        Applying fragment 'server-fragment.xml' to 'conf/server.xml'
        Applying fragment 'web-fragment.xml' to 'conf/web.xml'
        Applying fragment 'tomcat-users-fragment.xml' to 'conf/tomcat-users.xml'
        Applying fragment 'catalina-fragment.properties' to 'conf/catalina.properties'
      Applying template 'base-tomcat-6'
        Copying template's contents
        Applying fragment 'server-fragment.xml' to 'conf/server.xml'
        Applying fragment 'web-fragment.xml' to 'conf/web.xml'
      Applying template 'myapp'
        Copying template's contents
    create failed. com.springsource.tcruntime.instance.internal.properties.PropertyPlaceholderResolutionFailedException: Circular reference in property definitions: catalina.base -> catalina.base
    Template is very simple and contains only one property file under custom directory. Property file inside tries to use ${catalina.base} property:
    Code:
    [myapp@localhost tc-server]$ tree templates/myapp
    templates/myapp
    `-- myapp
        `-- myapp.properties
    
    1 directory, 1 file
    [myapp@localhost tc-server]$ cat templates/myapp/myapp/myapp.properties 
    myapp.log.location=${catalina.base}/logs
    [myapp@localhost tc-server]$
    So, the question why it is failing?


    Second question is why 'myapp' template applied before 'bio'? How is processing order defined?

  • #2
    Apologies, it looks like you've found a bug. ${catalina.base} should be left as-is during instance creation when it's found in a properties file (other than setenv.properties where it's replaced with either $CATALINA_BASE or %CATALINA_BASE% depending on the platform).

    I think you may still be able to make progress, though. Rather than having ${catalina.base} in your myapp.properties file, and requiring your code that reads it to parse ${catalina.base} and replace it with the appropriate value, it may be simpler to document that when myapp.log.location's value is a relative path, it's relative to catalina base. The code that reads and processes the property can access the value of catalina base using the CATALINA_BASE system property and use this to make the location absolute.

    The order in which templates are applied, and why you're seeing the bio template being applied, is described in the Creating a tc Runtime Instance with a Template section of the documentation.

    Comment


    • #3
      Originally posted by Andy Wilkinson View Post
      Apologies, it looks like you've found a bug. ${catalina.base} should be left as-is during instance creation when it's found in a properties file (other than setenv.properties where it's replaced with either $CATALINA_BASE or %CATALINA_BASE% depending on the platform).

      I think you may still be able to make progress, though. Rather than having ${catalina.base} in your myapp.properties file, and requiring your code that reads it to parse ${catalina.base} and replace it with the appropriate value, it may be simpler to document that when myapp.log.location's value is a relative path, it's relative to catalina base. The code that reads and processes the property can access the value of catalina base using the CATALINA_BASE system property and use this to make the location absolute.
      Yep, I'll found workaround which works for me. BTW, do you guys have public issue tracker/roadmap for tc Server?

      Originally posted by Andy Wilkinson View Post
      The order in which templates are applied, and why you're seeing the bio template being applied, is described in the Creating a tc Runtime Instance with a Template section of the documentation.
      The thing is that it applies 'bio' template but after the 'myapp' if there is no problem in 'myapp' template.

      Code:
      Creating instance 'myapp-instance2' ...
        Using separate layout
        Creating bin/setenv.sh
        Applying template 'base'
          Copying template's contents
          Applying fragment 'context-fragment.xml' to 'conf/context.xml'
          Applying fragment 'server-fragment.xml' to 'conf/server.xml'
          Applying fragment 'web-fragment.xml' to 'conf/web.xml'
          Applying fragment 'tomcat-users-fragment.xml' to 'conf/tomcat-users.xml'
          Applying fragment 'catalina-fragment.properties' to 'conf/catalina.properties'
        Applying template 'base-tomcat-7'
          Copying template's contents
          Applying fragment 'server-fragment.xml' to 'conf/server.xml'
          Applying fragment 'web-fragment.xml' to 'conf/web.xml'
          Applying fragment 'catalina-fragment.properties' to 'conf/catalina.properties'
        Applying template 'myapp'
          Copying template's contents
        Applying template 'bio'
          Copying template's contents
          Applying fragment 'server-fragment.xml' to 'conf/server.xml'
        Configuring instance 'myapp-instance2' to use Tomcat version 7.0.20.B.RELEASE
        Setting permissions
      Instance created
      Connector summary
        Port: 8080   Type: Blocking IO   Secure: false
      One more thing I've noticed, that if you are trying to override some JVM setting, like -Xmx in your template it doesn't work completely correctly. It just adds new value to JVM_OPTS keeping the overridden there too. It would be good if override value really substitute the values which come from base templates. Do you have any plans to support such functionality?

      Comment


      • #4
        Originally posted by Kirill Uvaev View Post
        The thing is that it applies 'bio' template but after the 'myapp' if there is no problem in 'myapp' template.

        Code:
        Creating instance 'myapp-instance2' ...
          Using separate layout
          Creating bin/setenv.sh
          Applying template 'base'
            Copying template's contents
            Applying fragment 'context-fragment.xml' to 'conf/context.xml'
            Applying fragment 'server-fragment.xml' to 'conf/server.xml'
            Applying fragment 'web-fragment.xml' to 'conf/web.xml'
            Applying fragment 'tomcat-users-fragment.xml' to 'conf/tomcat-users.xml'
            Applying fragment 'catalina-fragment.properties' to 'conf/catalina.properties'
          Applying template 'base-tomcat-7'
            Copying template's contents
            Applying fragment 'server-fragment.xml' to 'conf/server.xml'
            Applying fragment 'web-fragment.xml' to 'conf/web.xml'
            Applying fragment 'catalina-fragment.properties' to 'conf/catalina.properties'
          Applying template 'myapp'
            Copying template's contents
          Applying template 'bio'
            Copying template's contents
            Applying fragment 'server-fragment.xml' to 'conf/server.xml'
          Configuring instance 'myapp-instance2' to use Tomcat version 7.0.20.B.RELEASE
          Setting permissions
        Instance created
        Connector summary
          Port: 8080   Type: Blocking IO   Secure: false
        This is described in the last bullet in the list of high-level steps in the documentation I linked to previously. To paraphrase: the BIO template is being applied as, once all the user-specified templates have been applied, the instance's configuration is examined and if there are no connectors configured a BIO connector is added by applying the BIO template.

        Originally posted by Kirill Uvaev View Post
        One more thing I've noticed, that if you are trying to override some JVM setting, like -Xmx in your template it doesn't work completely correctly. It just adds new value to JVM_OPTS keeping the overridden there too. It would be good if override value really substitute the values which come from base templates. Do you have any plans to support such functionality?
        When specified in setenv.properties, -Xmx, -Xms, -Xss, and -XX:MaxPermsize should all be handled specially such that the largest value specified in any of the templates is used in the setenv.sh, setenv.sh and wrapper.conf files that are produced. It sounds like that's not happening for you. Can you provide a more specific of example of the templates you're using please?

        Comment


        • #5
          Thanks for pointing to exact location in docs, I've overlooked that. Now it is more clear.

          It looks like I've found root cause of the problem with -Xmx. Base template specifies memory settings in megabytes (-Xmx512m), but I've used gigabytes (-Xmx2g). If you use megabytes (-Xmx2048m) for override value it works fine.

          Comment


          • #6
            Thanks for the diagnosis, you analysis is spot on. The merging algorithm currently only considers K and M as possible units. I've opened an issue to improve the merging algorithm so that it considers G as well.

            Comment

            Working...
            X