You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Bas Schulte <ba...@gmail.com> on 2008/05/29 21:04:08 UTC
Configuring one webapp in 2 instances, system properties
Hi,
I'd like to deploy my Spring-based webapp twice in the same Tomcat
instance, one for production and one for development.
To configure my webapp, these distinct environments connect to
different database schema using different username/password combo's.
My spring configuration gets this from system properties, like this:
<bean id="someDataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/$
{sh.database.schema}"/>
...
</bean>
Is there a way to set these properties in server.xml for both
instance of my webapp? I plan on using 2 virtual hosts, something
like blah.com and development.blah.com, each would get it's own set
of system properties.
I already tried using environment entries, like this:
<Context ...>
...
<Environment name="sh.database.schema" value="shproduction"
type="java.lang.String" override="false"/>
...
</Context>
However, these aren't picked up by Spring.
How would I do this?
Regards,
bas.
---------------------------------------------------------------------
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: Configuring one webapp in 2 instances, system properties
Posted by "Lilianne E. Blaze" <li...@tlen.pl>.
You'll need something like that:
In Tomcat's:
<Environment name="shDatabase"
value="jdbc:mysql://127.0.0.1:3306/shproduction" type="java.lang.String"
override="false"/>
In Spring config:
<jee:jndi-lookup id="shDatabaseStr" jndi-name="shDatabase"/>
<bean ...>
<property name="url" ref="shDatabaseStr"/>
</bean>
Greetings, Lilianne E. Blaze
Bas Schulte wrote:
> Hi,
>
> I'd like to deploy my Spring-based webapp twice in the same Tomcat
> instance, one for production and one for development.
>
> To configure my webapp, these distinct environments connect to
> different database schema using different username/password combo's.
>
> My spring configuration gets this from system properties, like this:
>
> <bean id="someDataSource"
> class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
> <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
> <property name="url"
> value="jdbc:mysql://127.0.0.1:3306/${sh.database.schema}"/>
> ...
> </bean>
>
> Is there a way to set these properties in server.xml for both instance
> of my webapp? I plan on using 2 virtual hosts, something like blah.com
> and development.blah.com, each would get it's own set of system
> properties.
>
> I already tried using environment entries, like this:
>
> <Context ...>
> ...
> <Environment name="sh.database.schema" value="shproduction"
> type="java.lang.String" override="false"/>
> ...
> </Context>
>
> However, these aren't picked up by Spring.
>
> How would I do this?
>
> Regards,
>
> bas.
>
>
> ---------------------------------------------------------------------
> 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: Configuring one webapp in 2 instances, system properties
Posted by Gabe Wong <ga...@ngasi.com>.
Bas Schulte wrote:
> Hi,
>
> I tend to agree with both you and Chuck. However... ;)
>
> We're on a budget so separate servers is a no-op. Running multiple
> instances of Tomcat, with it's own start/stop script and it's own
> location for config files/libs etc. won't allow me to continue using
> debian's package management (I can already hear my sysadmin barfing at
> this solution). BTW, I do use this solution for activemq (there's no
> debian package for that ;)) and that's working fine.
Using a Tomcat build obtained directly from tomcat.apache.org will
enable you to easily run multiple installs. There in lies one of the
many problems and limitations
with the Linux Distros as they try to globalize the Java environment on
a system Such conventions work great for scripting languages like PHP
and Python.
Since Java applications are usually dependent on a specific version of
app server, jvm, and library, that way of thinking leads to unnecessary
problems.
>
> The solution of building instance-specific war's using ant would work
> but my current skills (combined with my deadline) fall short. I've
> done ant scripts by hand but currently use NetBeans as my ide and
> haven't figured out how I can combine those two things.
>
> I'll reconsider things, based on your input. Thanks.
>
>
>
> On 29-mei-2008, at 22:39, Christopher Schultz wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Bas,
>>
>> Bas Schulte wrote:
>> | I'd like to deploy my Spring-based webapp twice in the same Tomcat
>> | instance, one for production and one for development.
>>
>> I agree with Chuck: you are asking for trouble with a production
>> configuration that includes development.
>>
>> | Is there a way to set these properties in server.xml for both instance
>> | of my webapp? I plan on using 2 virtual hosts, something like blah.com
>> | and development.blah.com, each would get it's own set of system
>> properties.
>>
>> System properties are, as the name might suggest, system-wide. So, you
>> can't set "foo" to "bar" for one webapp and "baz" for the other. You
>> have to choose.
>>
>> This is one reason I eschew system properties for any application
>> configuration. We use ant to build our WAR files for deployment, and
>> find that ant's <filter> (string replacement) capabilities are a very
>> good way to configure for a particular environment.
>>
>> For instance. Want a dev config? Easy:
>>
>> $ ant -Drelease-type=dev war
>> (builds dev WAR)
>>
>> How about a prod config? No problem:
>>
>> $ and -Drelease-type=prod war
>>
>> No muss, no fuss.
>>
>> You maintain either different property values or entirely different
>> configuration files (which is what we have done) for each environment.
>> We have a prod/tomcat-server.xml and dev/tomcat-server.xml, each with
>> separate configuration (dev has only a single db connection in the pool,
>> for instance, while prod has many).
>>
>> - -chris
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.9 (MingW32)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>
>> iEYEARECAAYFAkg/FHgACgkQ9CaO5/Lv0PDqrQCfd8G/RW/fpg0eETU8qLl8XVno
>> C7MAoLgzo2yZFByJ7RCQSPrLip72XA5p
>> =a/25
>> -----END PGP SIGNATURE-----
>>
>> ---------------------------------------------------------------------
>> 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
>>
>
>
--
Regards
Gabe Wong
NGASI AppServer Manager
JAVA AUTOMATION and SaaS Enablement
http://www.ngasi.com
NEW! 8.1 - Centrally manage Application Servers across multiple physical servers
---------------------------------------------------------------------
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: Configuring one webapp in 2 instances, system properties
Posted by Bas Schulte <ba...@gmail.com>.
Hi,
I tend to agree with both you and Chuck. However... ;)
We're on a budget so separate servers is a no-op. Running multiple
instances of Tomcat, with it's own start/stop script and it's own
location for config files/libs etc. won't allow me to continue using
debian's package management (I can already hear my sysadmin barfing
at this solution). BTW, I do use this solution for activemq (there's
no debian package for that ;)) and that's working fine.
The solution of building instance-specific war's using ant would work
but my current skills (combined with my deadline) fall short. I've
done ant scripts by hand but currently use NetBeans as my ide and
haven't figured out how I can combine those two things.
I'll reconsider things, based on your input. Thanks.
On 29-mei-2008, at 22:39, Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Bas,
>
> Bas Schulte wrote:
> | I'd like to deploy my Spring-based webapp twice in the same Tomcat
> | instance, one for production and one for development.
>
> I agree with Chuck: you are asking for trouble with a production
> configuration that includes development.
>
> | Is there a way to set these properties in server.xml for both
> instance
> | of my webapp? I plan on using 2 virtual hosts, something like
> blah.com
> | and development.blah.com, each would get it's own set of system
> properties.
>
> System properties are, as the name might suggest, system-wide. So, you
> can't set "foo" to "bar" for one webapp and "baz" for the other. You
> have to choose.
>
> This is one reason I eschew system properties for any application
> configuration. We use ant to build our WAR files for deployment, and
> find that ant's <filter> (string replacement) capabilities are a very
> good way to configure for a particular environment.
>
> For instance. Want a dev config? Easy:
>
> $ ant -Drelease-type=dev war
> (builds dev WAR)
>
> How about a prod config? No problem:
>
> $ and -Drelease-type=prod war
>
> No muss, no fuss.
>
> You maintain either different property values or entirely different
> configuration files (which is what we have done) for each environment.
> We have a prod/tomcat-server.xml and dev/tomcat-server.xml, each with
> separate configuration (dev has only a single db connection in the
> pool,
> for instance, while prod has many).
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkg/FHgACgkQ9CaO5/Lv0PDqrQCfd8G/RW/fpg0eETU8qLl8XVno
> C7MAoLgzo2yZFByJ7RCQSPrLip72XA5p
> =a/25
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> 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
>
--
bas a schulte - http://
www.connectedcreations.nl - http://www.wittezeiltjes.nl -
http://www.wifistick.nl - http://www.golvendanser.nl
---------------------------------------------------------------------
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: Configuring one webapp in 2 instances, system properties
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Bas,
Bas Schulte wrote:
| I'd like to deploy my Spring-based webapp twice in the same Tomcat
| instance, one for production and one for development.
I agree with Chuck: you are asking for trouble with a production
configuration that includes development.
| Is there a way to set these properties in server.xml for both instance
| of my webapp? I plan on using 2 virtual hosts, something like blah.com
| and development.blah.com, each would get it's own set of system
properties.
System properties are, as the name might suggest, system-wide. So, you
can't set "foo" to "bar" for one webapp and "baz" for the other. You
have to choose.
This is one reason I eschew system properties for any application
configuration. We use ant to build our WAR files for deployment, and
find that ant's <filter> (string replacement) capabilities are a very
good way to configure for a particular environment.
For instance. Want a dev config? Easy:
$ ant -Drelease-type=dev war
(builds dev WAR)
How about a prod config? No problem:
$ and -Drelease-type=prod war
No muss, no fuss.
You maintain either different property values or entirely different
configuration files (which is what we have done) for each environment.
We have a prod/tomcat-server.xml and dev/tomcat-server.xml, each with
separate configuration (dev has only a single db connection in the pool,
for instance, while prod has many).
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkg/FHgACgkQ9CaO5/Lv0PDqrQCfd8G/RW/fpg0eETU8qLl8XVno
C7MAoLgzo2yZFByJ7RCQSPrLip72XA5p
=a/25
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
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: Configuring one webapp in 2 instances, system properties
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Bas Schulte [mailto:basschulte@gmail.com]
> Subject: Configuring one webapp in 2 instances, system properties
>
> I'd like to deploy my Spring-based webapp twice in the same Tomcat
> instance, one for production and one for development.
I strongly recommend that you don't do that - separate your development and production environments as much as possible. If you have only one box, at least run separate instances of Tomcat on it.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
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