tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glenn Nielsen <>
Subject Re: Webapp initialization (tomcat 4)
Date Wed, 16 May 2001 01:06:26 GMT
Tomcat 4.0 supports JNDI and JDBC DataSource pooling.

I configure a named JNDI JDBC DataSource in the <DefaultContext .. />,
which is then available to all web applications for a Host.

Here is an example from my server.xml (sensitive paramater data replaced with generic)

        <DefaultContext debug="0" reloadable="true">

          <!-- JNDI Named JDBC DataSource -->
          <Resource name="jdbc/test" auth="CONTAINER"
          <ResourceParams name="jdbc/test">

          <!-- JNDI Named MimePartDataSource for sending email via SMTP -->
          <Resource name="mail/send" auth="CONTAINER"
          <ResourceParams name="mail/send">




Peter Mutsaers wrote:
> Hello,
> I have some questions on webapp initialization.
> sorry to send this to both tomcat-user and tomcat-dev; since I use
> tomcat 4 I wasn't sure where to send this to. I hope that my questions
> are answered by some brand new, not yet documented features of
> tomcat-4 :)
> Browsing through documents, it seems like the only way to create some
> initial objects (such as a JDBC connection pool) in the ServetContext
> is to create a Servlet with load-on-startup, which then in its init()
> method can do some initialization.
> This seems a bit clumsy to me, since I don't really need the Servlet
> to handle requests. I just need some hook to initialize my
> ServletContext with some objects.
> Are there other (better) ways to do this?
> If not: can I force the Servlet to be destroyed after my init() is
> ready?
> Another topic: Am I correct in believing that
> ServletContext.getContext(uri) is the only way to obtain stuff from
> another webapps' ServletContext?
> In fact what I would like is to create a JDBC Connection Pool to be
> shared amongst various webapps. I could create this pool Object in one
> webapp (via the clumsy Servlet load-on-startup), then copy a reference
> to the ServletContexts of the other webapps. This creates some
> ordering problems (the other webapps may not run until the webapp
> setting up the connection pool is ready).
> It would be nicer if Tomcat, before initialising the webapps, would
> offer the possibility for me to run some code. This code (in my case
> creating the pool) should then create some initial context that all
> webapps can access (in order to create a reference in their own
> ServletContext).
> I was hoping that in servlet.xml, within the <Host> scope I could
> specify some Object to be shared between all <Context>'s.
> Is something like this available?
> After a day of searching through specs, mailing-list archives etc I
> hope someone can help me :)
> --
> Peter Mutsaers  |  Dübendorf    | UNIX - Live free or die
>      |  Switzerland  | Sent via FreeBSD 4.3-stable

Glenn Nielsen    | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |

View raw message