You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by David Soroko <da...@mannanetwork.com> on 2000/10/31 10:44:31 UTC

Strange behavior with context mapping and

I am observing the following behavior which I do not understand (Tomcat 3.1
and 3.2b6)

The setup:

The appdev Hello sample servlet to which the method  init (ServletConfig
config)
has been added. It just prints a line of text.

To the servlet's web.xml the <load-on-startup>1</load-on-startup> element
has been added

To the server.xml the Context element has been added:
       <Context path=""
                 docBase="webapps/myapp"
                 debug="0"
                 >
        </Context>


What I see, is that  when Tomcat starts the init() method is being invoked
twice.

Is this a correct behavior or is there something illegal about path="" ?

--
====================================================
David Soroko
Manna Inc.

http://www.geocities.com/SiliconValley/Campus/1628/
mailto://davids@mannanetwork.com
====================================================


Re: Strange behavior with context mapping and

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Hans Bergsten wrote:

>
> Once upon a time this happened when an application was defined by a <Context>
> element and stored in the default webapps directory. Tomcat created one context
> for the <Context> declaration and one for the the WAR (or expanded WAR) it found
> in the webapps directory.
>

Well, that's not it either ... it either doesn't fail in 3.2 or it has been fixed
already.

Oh well, much bigger fish yet to fry ... I'm working chronologically backwards and
am only back to last Monday's reports on TOMCAT-DEV :-(

Craig



Re: Strange behavior with context mapping and

Posted by Hans Bergsten <ha...@gefionsoftware.com>.
"Craig R. McClanahan" wrote:
> 
> David Soroko wrote:
> 
> > I am observing the following behavior which I do not understand (Tomcat 3.1
> > and 3.2b6)
> >
> > The setup:
> >
> > The appdev Hello sample servlet to which the method  init (ServletConfig
> > config)
> > has been added. It just prints a line of text.
> >
> > To the servlet's web.xml the <load-on-startup>1</load-on-startup> element
> > has been added
> >
> > To the server.xml the Context element has been added:
> >        <Context path=""
> >                  docBase="webapps/myapp"
> >                  debug="0"
> >                  >
> >         </Context>
> >
> > What I see, is that  when Tomcat starts the init() method is being invoked
> > twice.
> >
> > Is this a correct behavior or is there something illegal about path="" ?
> >
> 
> David,
> 
> Try as I might, I could not reproduce this with Tomcat 3.2 -- it always seems
> to call my init() method once and only once like it is supposed to.  The only
> thing I can think of that might trigger what you are seeing is if you edited
> the file $TOMCAT_HOME/conf/web.xml instead of the web.xml inside your web
> application -- that would cause the servlet to get loaded once per web
> application (at least under 3.1).
> 
> If this is not what you did, could you please zip up a copy of the web
> application directory you are using, so that I can reproduce exactly what you
> are seeing?

Once upon a time this happened when an application was defined by a <Context>
element and stored in the default webapps directory. Tomcat created one context
for the <Context> declaration and one for the the WAR (or expanded WAR) it found
in the webapps directory. 

I haven't tested if this is the case still, but it might be. If so, I suggest
you 
leave it as it is in 3.2. The simple work-around is to store applications
defined 
by <Context> elements somewhere else than in webapps.

Hans
-- 
Hans Bergsten		hans@gefionsoftware.com
Gefion Software		http://www.gefionsoftware.com

Re: Strange behavior with context mapping and

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
David Soroko wrote:

> I am observing the following behavior which I do not understand (Tomcat 3.1
> and 3.2b6)
>
> The setup:
>
> The appdev Hello sample servlet to which the method  init (ServletConfig
> config)
> has been added. It just prints a line of text.
>
> To the servlet's web.xml the <load-on-startup>1</load-on-startup> element
> has been added
>
> To the server.xml the Context element has been added:
>        <Context path=""
>                  docBase="webapps/myapp"
>                  debug="0"
>                  >
>         </Context>
>
> What I see, is that  when Tomcat starts the init() method is being invoked
> twice.
>
> Is this a correct behavior or is there something illegal about path="" ?
>

David,

Try as I might, I could not reproduce this with Tomcat 3.2 -- it always seems
to call my init() method once and only once like it is supposed to.  The only
thing I can think of that might trigger what you are seeing is if you edited
the file $TOMCAT_HOME/conf/web.xml instead of the web.xml inside your web
application -- that would cause the servlet to get loaded once per web
application (at least under 3.1).

If this is not what you did, could you please zip up a copy of the web
application directory you are using, so that I can reproduce exactly what you
are seeing?

> David Soroko
> Manna Inc.
>

Craig McClanahan