You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mohan Radhakrishnan <Mo...@hclcomnet.co.in> on 2002/12/30 05:22:15 UTC

application context loaded twice

Hi,
       Why would

        <Context path="" docBase="x" debug="0">

         load my application context twice?

My listener is called twice while the following line

        <Context path="name" docBase="x" debug="0">

loads it only once.

   What am I  missing ? Appreciate help.

Mohan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: application context loaded twice

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Mon, 30 Dec 2002, Mohan Radhakrishnan wrote:

> Date: Mon, 30 Dec 2002 09:52:15 +0530
> From: Mohan Radhakrishnan <Mo...@hclcomnet.co.in>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: Tomcat Users List <to...@jakarta.apache.org>
> Subject: application context loaded twice
>
> Hi,
>        Why would
>
>         <Context path="" docBase="x" debug="0">
>
>          load my application context twice?
>
> My listener is called twice while the following line
>
>         <Context path="name" docBase="x" debug="0">
>
> loads it only once.
>
>    What am I  missing ? Appreciate help.
>

Let's think for a moment about how Tomcat auto-deploys applications from
the "webapps" subdirectory.  Basically, it does the following:

* Scans all the <Context> elements that you've created,
  and deploys an app under the context path you specified.
  In the case of your first example, you're creating the
  "root" webapp for this virtual host from the contents
  of "$CATALINA_HOME/webapps/x".

* Scans all the directories in "webapps" to see if they
  contain a web application.  If so, they are deployed
  under a context path derived from the directory name.
  So, Tomcat sees directory "x" and deploys the *same*
  webapp under context path "/x".

If you do not want this to happen, you need to either ensure that the
directory name matches the context path without the leading slash (use
special directory name "ROOT" for the root webapp, since you cannot have a
zero-length filename on most OSs), or put your context directory someplace
other than "webapps" and use an absolute path for the docBase attribute.

So why didn't your second example load the app twice?  Simple -- "name" is
not a valid context path because it does not start with a slash, so this
<Context> entry was not loaded (although I'll bet there are log messages
that would tell you about this).

> Mohan
>

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>