tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Stewart <>
Subject RE: [Q] server.xml vs context.xml ?
Date Tue, 29 Jul 2003 14:41:19 GMT
Hi Riann,

I have successfully implemented a globally available DataSource within my
server.xml.  What follows are the relevant excerpts from my server.xml file
that enabled me to do this.  FYI - I am using Tomcat 4.1.24.

    The global DataSource definition

        <!-- Global JNDI resources -->

            <!-- Editable user database that can also be used by JNDI
DatabaseRealm to authenticate users -->
            <Resource name="jdbc/MySQLConnectPool" 
                      type="javax.sql.DataSource" />

            <ResourceParams name="jdbc/MySQLConnectPool" >



                    <value>jdbc:mysql://<your IP here>:3306/<your DB name


    Realm definition using global DataSource


    Context reference to global DataSource

        <ResourceLink name="jdbc/MySQLConnectPool"
                      type="javax.sql.DataSource" />

Hope this helps!!

Scott Stewart

-----Original Message-----
From: Riaan Oberholzer []
Sent: Tuesday, July 29, 2003 9:26 AM
Subject: [Q] server.xml vs context.xml ?

I've had the problem where defining a Datasource in a
server.xml (as sub element of the context element) did
not work, but moving it to a context.xml for the
application (named 'appname.xml' eg) it worked fine.

What is the general rule regarding when to declare
e.g. Datasources for a specific application in the
server.xml and when to put it in a context.xml? The
Tomcat HOW-TO documentation explains that you must do
it in the server.xml, but this doesn't sound like the
best solution to me.

Why would one method work and the other not? Pro's &
con's of each? The obvious difference is that updating
server.xml would require a server restart where
working with a context.xml does not. But in the
server.xml you can specify resources globally for for
all apps, right? I tried this first, but couldn't get
it working... only when the resource was specific to
my application could I actually use it without getting

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message