You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Thom Park <tp...@inprise.com> on 2000/11/27 21:49:27 UTC

missing welcome file causes CPU intensive loop

Hello,

I've noticed some curious behavior with Tomcat 3.2.beta 8. It seems that if the
'global' welcome file (index.html) is missing  then Tomcat will drop into
a CPU extensive loop (on NT at least)  The easiest way to reproduct this is as
follows;

1. rename %TOMCAT_HOME%\webapps to %TOMCAT_HOME%\webapps_hidden.
2. start tomcat
3. use your browser of choice to connect to http://localhost:8080/

If you bring up the NT taskmanager you'll see that the tomcat JVM is running at or
close to 100% { unless you've a multi cpu system ;-) }

I would have expected a 404 or something similar as there's no file to serve.
Has anyone else noticed this behavior or can suggest where in the source to look for
a possible cause (I need to fix this).

I tried enabling the "suppress" option on the StaticHandler class but it didn't
change the behavior.

-Thom


"Craig R. McClanahan" wrote:

> Miles Daffin wrote:
>
> > Craig,
> >
> > I was wondering if there is an optimal way of doing the following in TomCat?
> > If you have the time to briefly describe such....
> >
> > Thanks
> >
> > Miles
> >
> > > > >(I prefer to store global application
> > > > objects in
> > > > > the servlet context, so that they are easily visible to all servlets
> > and
> > > > JSP
> > > > > pages in my apps).
> >
> > p.s. please would you cc any response to my address.
>
> Yes, it's easy in Tomcat (or any other servlet container that implements servlet
> 2.2 or later).
>
> What I normally do is define a servlet to initialize my application resources,
> and declare it <load-on-startup> in the web.xml file (so that the time-consuming
> stuff happens when the server starts instead of on the first request).  As part
> of the init() method of this servlet, I store these resources as a servlet
> context attribute.
>
> For example, lets say you have a nice fancy connection pool object that you want
> to make available to the servlets and JSP pages of your application.  In the
> init() method of the startup servlet, you just need to do the following:
>
>     ConnectionPool myPool = ... create the pool object ...
>     getServletContext().setAttribute("pool", myPool);
>
> Now, any servlet in your application can acquire a reference to this pool in the
> doGet() or doPost() method:
>
>     ConnectionPool thePool =
>       (ConnectionPool) getServletContext().getAttribute("pool");
>
> Or, in a JSP page, you can access it like this:
>
>     <jsp:useBean id="pool" type="com.mycompany.ConnectionPool"
>      scope="application"/>
>
> Craig McClanahan


Re: missing welcome file causes CPU intensive loop

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

> Hello,
>
> I've noticed some curious behavior with Tomcat 3.2.beta 8. It seems that if the
> 'global' welcome file (index.html) is missing  then Tomcat will drop into
> a CPU extensive loop (on NT at least)  The easiest way to reproduct this is as
> follows;
>
> 1. rename %TOMCAT_HOME%\webapps to %TOMCAT_HOME%\webapps_hidden.
> 2. start tomcat
> 3. use your browser of choice to connect to http://localhost:8080/
>

I have documented this as a restriction in the release notes that will go out with 3.2
final.  It's too close to the final release to risk disrupting things by fixing an error
like this, which can be worked around quite easily by correctly configuring Tomcat.

Craig McClanahan