2 Replies Latest reply on Oct 29, 2013 8:33 AM by sfcoy

    Property File/Module per server group

    jjdevine

      Hi,

       

      I am migrating an application from JBoss 5 to JBoss AS 7.2. Previously the deployment had one JBoss installation with 3 configurations (live, test, training). I am trying to replicate this in JBoss 7.2 by setting up the AS in domain mode on a single physical machine with 3 server groups, called live, test and training. The application however uses a property file to load configuration data. As I understand it property files need to be deployed and accessed as modules, hence I have deployed the property files under a module that the application (an EAR file) references.

       

      The problem is that each server group needs a different copy of the property files (with different configuration data). Since the jboss-deployment-structure.xml that references the module is inside the EAR file, all 3 instances of the application point to the same module & property file. Is there some way of configuring the server group so that each one has its own (different) copy of this module, or so that each server group gets its own copies of the property file?

      Thanks,

        • 1. Re: Property File/Module per server group
          jjdevine

          To simply this a bit.. I'm basically deploying the same EAR file into two different server groups (live and test). The EAR file loads configuration from an external property file that currently sits in a custom module and is referenced from jboss-deployment-structure.xml, within the EAR file. The problem is that the contents of the property file needs to be different between the live and test version of the EAR file, but I'm not sure how to point the two server groups to different versions of the property file, given that the property file is within a module (in the single 'modules' folder), and I don't want to have to modify the EAR between the two server groups to use separate modules.

           

          I've had 2 ideas, but I don't like either of them:

           

          a) Set up a 'live' and 'test' profile in domain.xml, and use the <global-modules> element to reference a different module for each profile, one containing the live version of the property file, and the other containing the test version of the property file. The 'live' server group can then use the 'live' profile, and the 'test' server group can use the 'test' profile. The problem with this is that I would then have two lengthy profile declarations that are almost identical except for the module declaration. Is there a better solution that this? Is there a way of declaring a 'parent' profile, and then the live and test profiles can inherit from the 'parent', and just declare the global modules section since this is the only difference between them?

           

          b) Get rid of the external property files and change the application to look up the configuration via JNDI. This may be the 'best practice' way but it would involve a lot of changes to the application that we don't really have the time for right now, plus the application also gets deployed on weblogic so all our config for that would have to be redone.

          • 2. Re: Re: Property File/Module per server group
            sfcoy
            1. Put all of the the properties files in the same module, but (say) prefixed with the environment name. For instance,  live-config.properties, test-config.properties, etc.
            2. Define a single JNDI binding in the naming configuration for each profile:
              <subsystem xmlns="urn:jboss:domain:naming:1.2"> <!-- use the right version for your server here! -->
                <bindings>
                  <simple name="java:/jboss/env-name" value="live"/>
                </bindings>
              </subsystem>
              
            3. Look this up (or better - inject it), and use the value to select which properties file to read.
            1 of 1 people found this helpful