Hi All, Thank you for the responses I received.
>From the responses it's clear to me that I do _not_ understand the mechanism of how contexts are specified and generated. I've read through the Tomcat documentation, and gone through the email-list-archives, and am still confused. Can someone explain? Once I do understand, I'd be happy to clean it up and turn it into a FAQ. Here is what I _think_ I understand: 1. The server.xml file can contain any number of <context> directives 2. It also _must_ contain a context with path="" as the default context 3. In addition, any web-apps that appear in the <Host> directives appBase will have a context generated for them Here is what I _don't_ understand: Q1. Why can't I declare a <Context> with a path (e.g. "/foo") and also use this app as my default context WITHOUT having it LOADED TWICE? It seems that if I have two <Context> entries--one with path="/foo" to handle the "myserver/foo" requests, and another to set it as the default, the App gets loaded twice. Q2. What happens when I put an explicit Context entry in server.xml for an application that sits in my hosts appBase? I do this to explicitly set parameters like 'path'. I would expect the explicit Context entry in server.xml to superseed any generated context, but again, the app seems to get loaded twice. Q3. In the Tomcat documentation for the <Host> directive, it's mentioned that you can use .xml files to explicity create Contexts outside of server.xml. But it isn't clear on where you put these. I quote: "Any XML file in this directory is assumed to contain a Context element " Ok, but what is THIS directory? AppBase? Web-application directory? WEB-INF in a Webapp?? Here is a link to the unclear docs: http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/host.html#Automatic%2 0Application%20Deployment Q4. How do these 4 kinds of Context specifications interact: - server.xml entries - server.xml default context (not the <defalutContext> directive, the <context path=""> directive) - separate context .xml files - auto-generated contexts for web-apps in the AppBase directory Specifically how can I: - Explicitly specify context parameters - Satisfy the requirement that there be a default context (path="") - NOT have my app loaded multiple times ???? Thanks in advance for all your help. As you can tell, I'm getting pretty frustrated! - jeff ----- Original Message ----- From: "Michael Petres" <[EMAIL PROTECTED]> To: "Tomcat Users List" <[EMAIL PROTECTED]> Sent: Tuesday, September 10, 2002 3:56 PM Subject: RE: Servlet's loading twice on start-up--DRIVING ME NUTS! > Tomcat will (upon startup) scan the appBase="..." directory (default is > 'webapps') by default and will load any web applications located there. In > addition if you have a context defined, it will also load the app again! > > Try placing your web application some other place but 'webapps' and make > sure you specify the absolute path in the docBase of your context tag. > > Michael Petres > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > InnovObjX Corp. > Web: www.innovobjx.com > Tel: 905-729-2235 x3 > Fax: 905-729-2235 > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > -----Original Message----- > From: Jeff Wishnie [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, September 10, 2002 6:53 PM > To: Tomcat Users List > Subject: Servlet's loading twice on start-up--DRIVING ME NUTS! > > I have a very simple Tomcat install with one application. The web.xml for > the applicaiton loads two servlets on start-up. > > According to my logs both servlets have their init() methods called _twice_. > > I've looked through the list archives and gone through the mentionned causes > of this problem and, assuming I understand the issues, have ruled them out. > > 1. The servlets are _not_ throwing exceptions > > 2. I have only _one_ context defined in server.xml and it is _not_ the > default context. > > I'm going nuts here and would be very grateful for any help folks on the > list can provide. > > Here are the details of my set-up: > > Tomcat: 4.1.7-LE > JDK: 1.4.0_01 > OS: Redhat 7.2 > > Tomcat layout: > > One web application in: $TOMCAT_HOME/ROOT/MyApp > > Here are revelant sections from $TOMCAT_HOME/conf/server.xml: > > <Host name="localhost" debug="0" appBase="ROOT" unpackWARs="true" > autoDeploy="false"> > <Logger className="org.apache.catalina.logger.FileLogger" > directory="logs" prefix="localhost_log." suffix=".txt" > timestamp="true"/> > <Context path="/" docBase="DeluxeCal" debug="0" crossContext="false" > reloadable="false" /> > </Host> > > [note that "autoDeploy" and "reloadable" are false and that the Context > path="/", _not_ ""] > > Here are relevent sections from $TOMCAT_HOME/ROOT/MyApp/WEB-INF/web,xml: > > <servlet> > <servlet-name>initServlet</servlet-name> > <servlet-class>com.foo.InitServlet</servlet-class> > <load-on-startup>10</load-on-startup> > </servlet> > > <servlet> > <servlet-name>serviceInit</servlet-name> > <servlet-class>com.foo.ServiceInitServlet</servlet-class> > <init-param> > <param-name>endpoint</param-name> > <param-value>http://foo.com/service/bar?wsdl</param-value> > </init-param> > <load-on-startup>20</load-on-startup> > </servlet> > > Why is Init getting called TWICE for each servlet?? > > Help! > > Thanks! > > - Jeff > > > -- > 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]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
