What you describe isn't a bug -- it's a direct consequence of the way auto-mount works in the "appBase" directory of a Host (i.e. the "webapps" directory).
Normally, Tomcat examines all the contents of the "webapps" directory, and (if it's a WAR or a directory) tries to automatically mount a webapp with the corresponding name as the context path -- thus the "examples" directory is automatically mounted at context path "/examples", the "tomcat-docs" directory is automatically mounted at "/tomcat-docs", and so on. The root directory is a case where we can't do this -- conforming to this pattern would require us to have a zero-length pathname, which most OSs are not too happy with. Therefore, there is a special case that the directory name ROOT will be mounted as the root webapp. If you don't want two instances of you webapp, it's really very simple: * Don't change the docBase for the ROOT partition * Use an absolute docBase that points to a directory not under webapps. By the way, you can cause the same sort of problem with any other context that is explicitly configured in server.xml -- for example, add a new <Context> entry just before the one for "/examples" like this, and see what happens:: <Context path="/foo" docBase="examples"/> Craig On Mon, 29 Jul 2002, peter lin wrote: > Date: Mon, 29 Jul 2002 08:48:38 -0400 > From: peter lin <[EMAIL PROTECTED]> > Reply-To: Tomcat Developers List <[EMAIL PROTECTED]> > To: Tomcat Developers List <[EMAIL PROTECTED]> > Subject: ServletContextListener bug #11043 > > > I've posted this question last week and talked to Remmy, but Remmy is > busy with moving. I spent some time this weekend trying to track down > the bug, but couldn't figure it out. I'm hoping if I describe the bug > more clearly, someone can point me in the right direction. > > The bug is the following: > > If I have server.xml set with all the defaults and I have a > ServletContextListener defined in web.xml, Tomcat correctly creates an > instance of my listener and starts my test application. If I add a > webapp, it also correctly creates an instance of my listener and starts > the test application. > > > If on the otherhand I change server.xml to point to a different > directory for the default root path from "ROOT" to say "myapp", Tomcat > ends up creating two separate instances of the listener. Both listeners > get contextInitialized() event and create one instance of my test > application per listener. The correct behavior should be the same as > leaving the root directory to the default "ROOT". > > If I use 4.1.8 and load up the manager, I see webapp "/" and "/myapp". > This explains why two separate instances of my listener are created. I > only want 1 instance of my test application to startup with tomcat, > since it loads global configuration values into memory. > > I looked in catalina.core.StandardContext, but I don't see which class > is responsible for creating the listener listed in web.xml. Is the > behavior of creating two instances of my listener according to > specification? Is there something special about changing the default > root path from "ROOT" to some other "myapp" path? > > > peter lin > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>