You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Alec Swan <al...@gmail.com> on 2010/09/14 23:04:11 UTC
Virtual host deployment
Hello,
I have a WAR file which I distribute to multiple servers with multiple
virtual hosts. On each server I have a database, which is accessed by all
virtual host apps on this server.
Is it the right approach to put database access credentials in
$TOMCAT/conf/context.xml which will then be loaded by each virtual host app
or should I put them somewhere else?
Thanks
RE: Virtual host deployment
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Alec Swan [mailto:alecswan@gmail.com]
> Subject: Re: Virtual host deployment
> So, the database credentials should be stored somewhere
> in the server configuration.
Then place the <Context> element in conf/Catalina/[host]/[appName].xml. Should you really need multiple <Host> elements, your deployment script should be able to create each .xml file as it copies the .war files.
- 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 unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Virtual host deployment
Posted by Pid <pi...@pidster.com>.
On 15/09/2010 04:46, Alec Swan wrote:
> Could anybody explain what is the advantage of configuring JNDI resources
> using GlobalNamingResources in server.xml over configuring them in
> TOMCAT/conf/context.xml?
If configured in global, 1 db pool is created and then referenced/shared
by multiple apps.
If configured in conf/context.xml it is a base config for each app, so
multiple pools are created. You probably don't want that.
p
> On Tue, Sep 14, 2010 at 4:36 PM, Mark Thomas <ma...@apache.org> wrote:
>
>> On 14/09/2010 23:33, Alec Swan wrote:
>>> Thanks, I'll give it a try.
>>>
>>> Still kind of curious if GlobalResources override resources in
>>> META-INF/context.xml, but I guess I will find that out soon.
>>
>> They are in different JNDI name spaces so no. (which is why you need to
>> use a ResourceLink)
>>
>> Mark
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
Re: Virtual host deployment
Posted by Alec Swan <al...@gmail.com>.
Could anybody explain what is the advantage of configuring JNDI resources
using GlobalNamingResources in server.xml over configuring them in
TOMCAT/conf/context.xml?
Thanks!
Alec
On Tue, Sep 14, 2010 at 4:36 PM, Mark Thomas <ma...@apache.org> wrote:
> On 14/09/2010 23:33, Alec Swan wrote:
> > Thanks, I'll give it a try.
> >
> > Still kind of curious if GlobalResources override resources in
> > META-INF/context.xml, but I guess I will find that out soon.
>
> They are in different JNDI name spaces so no. (which is why you need to
> use a ResourceLink)
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
Re: Virtual host deployment
Posted by Mark Thomas <ma...@apache.org>.
On 14/09/2010 23:33, Alec Swan wrote:
> Thanks, I'll give it a try.
>
> Still kind of curious if GlobalResources override resources in
> META-INF/context.xml, but I guess I will find that out soon.
They are in different JNDI name spaces so no. (which is why you need to
use a ResourceLink)
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Virtual host deployment
Posted by Alec Swan <al...@gmail.com>.
Thanks, I'll give it a try.
Still kind of curious if GlobalResources override resources in
META-INF/context.xml, but I guess I will find that out soon.
On Tue, Sep 14, 2010 at 4:13 PM, Pid <pi...@pidster.com> wrote:
> On 14/09/2010 23:10, Alec Swan wrote:
> > GlobalResources sounds like what I am looking for. According this page (
> > http://tomcat.apache.org/tomcat-6.0-doc/config/globalresources.html) it
> > seems like I need to just add the following configuration in server.xml:
> >
> > <GlobalNamingResources ...>
> > ...
> > <Resource name="jdbc/EmployeeDB" auth="Container"
> > type="javax.sql.DataSource"
> > description="Employees Database for HR Applications"/>
> > ...
> > </GlobalNamingResources>
> >
> >
> > If I understand correctly, this will make jdbc/EmployeeDB JNDI resource
> > available to every web application deployed in the container, correct?
> > Will it override the JNDI resource definition packaged in
> > META-INF/context.xml inside of the WAR file?
>
> You can then remove that resource def.
>
> You'll need a ResourceLink in the Context definition to make the global
> resource available to webapps - but this can be standard, regardless of
> dev/prod.
>
>
> p
>
>
Re: Virtual host deployment
Posted by Pid <pi...@pidster.com>.
On 14/09/2010 23:10, Alec Swan wrote:
> GlobalResources sounds like what I am looking for. According this page (
> http://tomcat.apache.org/tomcat-6.0-doc/config/globalresources.html) it
> seems like I need to just add the following configuration in server.xml:
>
> <GlobalNamingResources ...>
> ...
> <Resource name="jdbc/EmployeeDB" auth="Container"
> type="javax.sql.DataSource"
> description="Employees Database for HR Applications"/>
> ...
> </GlobalNamingResources>
>
>
> If I understand correctly, this will make jdbc/EmployeeDB JNDI resource
> available to every web application deployed in the container, correct?
> Will it override the JNDI resource definition packaged in
> META-INF/context.xml inside of the WAR file?
You can then remove that resource def.
You'll need a ResourceLink in the Context definition to make the global
resource available to webapps - but this can be standard, regardless of
dev/prod.
p
Re: Virtual host deployment
Posted by Alec Swan <al...@gmail.com>.
GlobalResources sounds like what I am looking for. According this page (
http://tomcat.apache.org/tomcat-6.0-doc/config/globalresources.html) it
seems like I need to just add the following configuration in server.xml:
<GlobalNamingResources ...>
...
<Resource name="jdbc/EmployeeDB" auth="Container"
type="javax.sql.DataSource"
description="Employees Database for HR Applications"/>
...
</GlobalNamingResources>
If I understand correctly, this will make jdbc/EmployeeDB JNDI resource
available to every web application deployed in the container, correct?
Will it override the JNDI resource definition packaged in
META-INF/context.xml inside of the WAR file?
Thanks!
On Tue, Sep 14, 2010 at 3:58 PM, Pid <pi...@pidster.com> wrote:
> On 14/09/2010 22:52, Alec Swan wrote:
> > Hi Chris,
> >
> > Thank you for the defaultHost recommendation.
> >
> > The deployment scenario I would like to support requires deploying the
> same
> > WAR file on the development server first and then on the production
> server.
> > Development and production servers use different database credentials, so
> I
> > cannot package them in the WAR file itself. So, the database credentials
> > should be stored somewhere in the server configuration.
> >
> > What is the recommended way to support this scenario? Is there any other
> > place besides conf/context.xml where I can store server-specific DB
> > credentials?
>
> You're not defining the DB Resource in GlobalResources?
>
>
> p
>
> > Thanks,
> >
> > Alec
> >
> > On Tue, Sep 14, 2010 at 3:18 PM, Christopher Schultz <
> > chris@christopherschultz.net> wrote:
> >
> > Alec,
> >
> > On 9/14/2010 5:04 PM, Alec Swan wrote:
> >>>> I have a WAR file which I distribute to multiple servers with multiple
> >>>> virtual hosts. On each server I have a database, which is accessed by
> all
> >>>> virtual host apps on this server.
> >
> > I'm interested: is the WAR actually identical, including all settings
> > for all virtual hosts? If so, you can save yourself a lot of memory and
> > database connections by deploying a single copy to a single <Host> and
> > either setting that host as the "defaultHost" for the <Service> or using
> > <Aliases> within the <Host>.
> >
> >>>> Is it the right approach to put database access credentials in
> >>>> $TOMCAT/conf/context.xml
> >
> > No. You shouldn't really modify conf/context.xml unless you have a
> > really really good reason to do so.
> >
> >>>> which will then be loaded by each virtual host app
> >>>> or should I put them somewhere else?
> >
> > Put the <Resource> for your database connection pool into your webapp's
> > META-INF/context.xml file.
> >
> > -chris
> >>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
>
>
Re: Virtual host deployment
Posted by Pid <pi...@pidster.com>.
On 14/09/2010 22:52, Alec Swan wrote:
> Hi Chris,
>
> Thank you for the defaultHost recommendation.
>
> The deployment scenario I would like to support requires deploying the same
> WAR file on the development server first and then on the production server.
> Development and production servers use different database credentials, so I
> cannot package them in the WAR file itself. So, the database credentials
> should be stored somewhere in the server configuration.
>
> What is the recommended way to support this scenario? Is there any other
> place besides conf/context.xml where I can store server-specific DB
> credentials?
You're not defining the DB Resource in GlobalResources?
p
> Thanks,
>
> Alec
>
> On Tue, Sep 14, 2010 at 3:18 PM, Christopher Schultz <
> chris@christopherschultz.net> wrote:
>
> Alec,
>
> On 9/14/2010 5:04 PM, Alec Swan wrote:
>>>> I have a WAR file which I distribute to multiple servers with multiple
>>>> virtual hosts. On each server I have a database, which is accessed by all
>>>> virtual host apps on this server.
>
> I'm interested: is the WAR actually identical, including all settings
> for all virtual hosts? If so, you can save yourself a lot of memory and
> database connections by deploying a single copy to a single <Host> and
> either setting that host as the "defaultHost" for the <Service> or using
> <Aliases> within the <Host>.
>
>>>> Is it the right approach to put database access credentials in
>>>> $TOMCAT/conf/context.xml
>
> No. You shouldn't really modify conf/context.xml unless you have a
> really really good reason to do so.
>
>>>> which will then be loaded by each virtual host app
>>>> or should I put them somewhere else?
>
> Put the <Resource> for your database connection pool into your webapp's
> META-INF/context.xml file.
>
> -chris
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
Re: Virtual host deployment
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Alec,
On 9/14/2010 5:52 PM, Alec Swan wrote:
> The deployment scenario I would like to support requires deploying the same
> WAR file on the development server first and then on the production server.
> Development and production servers use different database credentials, so I
> cannot package them in the WAR file itself. So, the database credentials
> should be stored somewhere in the server configuration.
>
> What is the recommended way to support this scenario? Is there any other
> place besides conf/context.xml where I can store server-specific DB
> credentials?
Uh, uf my.war -C prod META-INF/context.xml
?
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkyQ18AACgkQ9CaO5/Lv0PBAFQCeJmvV+Gn0otTj0WWW1QAWUkXO
9PMAn2GdeptWiY/7D2+oJal8P284xfXw
=JKMm
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Virtual host deployment
Posted by Alec Swan <al...@gmail.com>.
Hi Chris,
Thank you for the defaultHost recommendation.
The deployment scenario I would like to support requires deploying the same
WAR file on the development server first and then on the production server.
Development and production servers use different database credentials, so I
cannot package them in the WAR file itself. So, the database credentials
should be stored somewhere in the server configuration.
What is the recommended way to support this scenario? Is there any other
place besides conf/context.xml where I can store server-specific DB
credentials?
Thanks,
Alec
On Tue, Sep 14, 2010 at 3:18 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Alec,
>
> On 9/14/2010 5:04 PM, Alec Swan wrote:
> > I have a WAR file which I distribute to multiple servers with multiple
> > virtual hosts. On each server I have a database, which is accessed by all
> > virtual host apps on this server.
>
> I'm interested: is the WAR actually identical, including all settings
> for all virtual hosts? If so, you can save yourself a lot of memory and
> database connections by deploying a single copy to a single <Host> and
> either setting that host as the "defaultHost" for the <Service> or using
> <Aliases> within the <Host>.
>
> > Is it the right approach to put database access credentials in
> > $TOMCAT/conf/context.xml
>
> No. You shouldn't really modify conf/context.xml unless you have a
> really really good reason to do so.
>
> > which will then be loaded by each virtual host app
> > or should I put them somewhere else?
>
> Put the <Resource> for your database connection pool into your webapp's
> META-INF/context.xml file.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkyP5psACgkQ9CaO5/Lv0PAjswCeJnaG3E5zW3thH5e+l6e9seES
> b2IAn3qmhJbwiUtPfsX7tIGQiotuvTm/
> =eqpa
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
Re: Virtual host deployment
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Alec,
On 9/14/2010 5:04 PM, Alec Swan wrote:
> I have a WAR file which I distribute to multiple servers with multiple
> virtual hosts. On each server I have a database, which is accessed by all
> virtual host apps on this server.
I'm interested: is the WAR actually identical, including all settings
for all virtual hosts? If so, you can save yourself a lot of memory and
database connections by deploying a single copy to a single <Host> and
either setting that host as the "defaultHost" for the <Service> or using
<Aliases> within the <Host>.
> Is it the right approach to put database access credentials in
> $TOMCAT/conf/context.xml
No. You shouldn't really modify conf/context.xml unless you have a
really really good reason to do so.
> which will then be loaded by each virtual host app
> or should I put them somewhere else?
Put the <Resource> for your database connection pool into your webapp's
META-INF/context.xml file.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkyP5psACgkQ9CaO5/Lv0PAjswCeJnaG3E5zW3thH5e+l6e9seES
b2IAn3qmhJbwiUtPfsX7tIGQiotuvTm/
=eqpa
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org