You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Paul Mendelson <pm...@plexsci.com> on 2006/06/27 18:47:19 UTC

RE: [SPAM] RE: Best Practice for properties files

Richard,

Thanks for the suggestion.  I appreciate the elegance of your ant
targets to create war files targeted for each runtime environment.

The reason that I am looking for a different approach is this approach
would require me to create a new war file if the managers of the runtime
environment want to reconfigure.

I'm trying to find ways that I can put more configuration information
outside of the war file, perhaps in the context.xml or in some file that
context.xml references.

Paul

-----Original Message-----
From: Richard Mixon [mailto:rnmixon@qwest.net] 
Sent: Saturday, June 24, 2006 9:44 PM
To: 'Tomcat Users List'
Subject: [SPAM] RE: Best Practice for properties files

Paul, are you using the deployer application to deploy your app (e.g.
apache-tomcat-5.5.17-deployer)?

If so, then it is very easy to modify the build.xml to customize the
log4j.properties, app.properties and any other file, and then deploy it
properly. You could even have a different ant target for each different
instance of the webapp.war file.

Here's an example of the build.xml that we setup. In this case most of
the
example deals with setting the JDBC connection to the correct database.

HTH - Richard

  ...
  <!--
===================================================================
-->
  <!-- Deploy for development (basically customize and copy to webapps
dir
-->
  <!--
===================================================================
-->
  <target name="devDeploy" description="Development Deploy"
          depends="clean,customizeContext">

  ... <!--- note we added the "customizeContext" target in the above
depends
-->

  <!-- The target below can have anything you wish in it -->
  <!--
===================================================================
-->
  <!-- Customize context for web application
-->
  <!--
===================================================================
-->
  <target name="customizeContext"
      description="Customizes web application context if its stored in
META-INF/${webapp}.xml">
      <!-- Customizing ${webapp.path}/META-INF/${webapp}.xml -->
      <echo level="info">Customizing
${webapp.path}/META-INF/${webapp}.xml</echo>
      <move tofile="${webapp}/META-INF/context.xml_bak"
              file="${webapp}/META-INF/context.xml"
         overwrite="false" failonerror="false"/>
      <delete file="${webapp}/META-INF/context.xml"
failonerror="false"/>
      <echo level="info">Changing hibernate.connection.driver_class to
${jdbc.connection.driver_class}</echo>
      <copy tofile="${webapp}/META-INF/context.xml"
              file="${webapp}/META-INF/context.xml_bak"
              overwrite="true" failonerror="true" verbose="true">
            <filterset>
                <filter token="webapp.name" value="${webapp.name}"/>
                <filter token="docbase.dir" value="${docbase.dir}"/>
                <filter token="workdir.dir" value="${workdir.dir}"/>
                <filter token="database.url" value="${database.url}"/>
                <filter token="app.username" value="${app.username}"/>
                <filter token="app.password" value="${app.password}"/>
            </filterset>
      </copy>
      ...
  </target>

-----Original Message-----
From: Paul Mendelson [mailto:pmendelson@plexsci.com] 
Sent: Friday, June 23, 2006 9:46 AM
To: Tomcat Users List
Subject: Best Practice for properties files

I have a fairly normal application that I am deploying on a tomcat 5.5
server.

My application uses log4j for its internal logging and I have a
log4j.properties file that I keep in web/WEB-INF/classes.  I also have a
regular app.properties file that I keep in web/WEB-INF.

I deploy my application to my tomcat server by placing app.war in the
proper
directory.

My question is if I am running my application on 4 or 5 different tomcat
servers and toe log4j.properties and app.properties file needs to be set
up
different on each server what is the best way to deploy and maintain
those
files?  I very much want to create a single app.war file and let each
system
administrator customer there properties without needing to synchronize
with
me.

Any advice is appreciated.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe,
e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: [SPAM] RE: Best Practice for properties files

Posted by Richard Mixon <rn...@qwest.net>.
Paul,

I can understand the reluctance to create and deploy the war just to change
a configuration setting - it seems so "heavyweight".

You could try a variation and have an ant target (or a shell script for that
matter) update the properties under WEB-INF from a know location that is
custom for each webapp context. Just remember  you will probably need to do
a reload on the context to make the configuration changes effective ... Or
you will need to write code that checks for resource changes periodically
and reloads them.

HTH - Richard


-----Original Message-----
From: Paul Mendelson [mailto:pmendelson@plexsci.com] 
Sent: Tuesday, June 27, 2006 9:47 AM
To: Tomcat Users List; rnmixon@qwest.net
Subject: RE: [SPAM] RE: Best Practice for properties files

Richard,

Thanks for the suggestion.  I appreciate the elegance of your ant targets to
create war files targeted for each runtime environment.

The reason that I am looking for a different approach is this approach would
require me to create a new war file if the managers of the runtime
environment want to reconfigure.

I'm trying to find ways that I can put more configuration information
outside of the war file, perhaps in the context.xml or in some file that
context.xml references.

Paul

-----Original Message-----
From: Richard Mixon [mailto:rnmixon@qwest.net]
Sent: Saturday, June 24, 2006 9:44 PM
To: 'Tomcat Users List'
Subject: [SPAM] RE: Best Practice for properties files

Paul, are you using the deployer application to deploy your app (e.g.
apache-tomcat-5.5.17-deployer)?

If so, then it is very easy to modify the build.xml to customize the
log4j.properties, app.properties and any other file, and then deploy it
properly. You could even have a different ant target for each different
instance of the webapp.war file.

Here's an example of the build.xml that we setup. In this case most of the
example deals with setting the JDBC connection to the correct database.

HTH - Richard

  ...
  <!--
===================================================================
-->
  <!-- Deploy for development (basically customize and copy to webapps dir
-->
  <!--
===================================================================
-->
  <target name="devDeploy" description="Development Deploy"
          depends="clean,customizeContext">

  ... <!--- note we added the "customizeContext" target in the above depends
-->

  <!-- The target below can have anything you wish in it -->
  <!--
===================================================================
-->
  <!-- Customize context for web application
-->
  <!--
===================================================================
-->
  <target name="customizeContext"
      description="Customizes web application context if its stored in
META-INF/${webapp}.xml">
      <!-- Customizing ${webapp.path}/META-INF/${webapp}.xml -->
      <echo level="info">Customizing
${webapp.path}/META-INF/${webapp}.xml</echo>
      <move tofile="${webapp}/META-INF/context.xml_bak"
              file="${webapp}/META-INF/context.xml"
         overwrite="false" failonerror="false"/>
      <delete file="${webapp}/META-INF/context.xml"
failonerror="false"/>
      <echo level="info">Changing hibernate.connection.driver_class to
${jdbc.connection.driver_class}</echo>
      <copy tofile="${webapp}/META-INF/context.xml"
              file="${webapp}/META-INF/context.xml_bak"
              overwrite="true" failonerror="true" verbose="true">
            <filterset>
                <filter token="webapp.name" value="${webapp.name}"/>
                <filter token="docbase.dir" value="${docbase.dir}"/>
                <filter token="workdir.dir" value="${workdir.dir}"/>
                <filter token="database.url" value="${database.url}"/>
                <filter token="app.username" value="${app.username}"/>
                <filter token="app.password" value="${app.password}"/>
            </filterset>
      </copy>
      ...
  </target>

-----Original Message-----
From: Paul Mendelson [mailto:pmendelson@plexsci.com]
Sent: Friday, June 23, 2006 9:46 AM
To: Tomcat Users List
Subject: Best Practice for properties files

I have a fairly normal application that I am deploying on a tomcat 5.5
server.

My application uses log4j for its internal logging and I have a
log4j.properties file that I keep in web/WEB-INF/classes.  I also have a
regular app.properties file that I keep in web/WEB-INF.

I deploy my application to my tomcat server by placing app.war in the proper
directory.

My question is if I am running my application on 4 or 5 different tomcat
servers and toe log4j.properties and app.properties file needs to be set up
different on each server what is the best way to deploy and maintain those
files?  I very much want to create a single app.war file and let each system
administrator customer there properties without needing to synchronize with
me.

Any advice is appreciated.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe,
e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe,
e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org