You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jason Burrows <ja...@gmail.com> on 2005/12/01 02:29:26 UTC

Problem with default context when moving from 5.5.7 to 5.5.12

Hi all -

I have recently upgraded from Tomcat 5.5.7 to 5.5.12 and now I am
having problems getting my default context to work correctly.  I very
well may have been doing this incorrectly the first time, but I still
need to figure out how to get it working again.  In this specific
case, I am trying to get Tomcat to use an external directory for the
docBase for development purposes, and as I say, it was working
correctly before.  For the moment, I have no other webapps installed
at all.

Previously, I had a context.xml file in my tomcat\conf directory with
this context tag (removed sub elements for brevity):

<Context path="" reloadable="false" docBase="c:\eclipse\myProject"
crossContext="true">
</Context>

This worked fine for me in 5.5.7 (on many machines).

After installing 5.5.12, I see there is a context element in this file
already.  If I replace it with mine, it changes nothing (Tomcat starts
and loads no webapps).  If I add mine to the file, it also changes
nothing.  I can in fact add garbage or poorly formed XML to this file
and Tomcat will start up correctly, loading no web apps, reporting no
errors.  No matter what I do to this file, Tomcat loads, but does not
load my application.

If I take my old context.xml file and move it to
tomcat\conf\Catalina\localhost, then it will load my application (I
can tell from log output, but I cannot access the servlets at all). 
This also causes the context.xml file in tomcat\conf to be loaded as
well, and if I have errors there they will be reported.  I should also
mention that in all of these cases (if my app is loading or not
loading) when I point my web browser at http://localhost I get a blank
page with no content.  I get the same result no matter what I put
there, even things I'd expect an error for like
http://localhost/test/blablabla/asfdd.html.  Tomcat doesn't even
generate errors about these attempts in the logs, it just reports that
everything started up correctly, the server is running, and that's the
last I hear from it.

So this tells me this:
5.5.7 would read tomcat\conf\context.xml all the time, but 5.5.12 will
only read it if you have a context file for your specific host (I
imagine it would also read this file if you had a webapp in the
webapps folder as well, but I don't).

In the change logs from 5.5.7 to 5.5.12, the only references I can see
related to the context.xml file are:

-Harmonize processing of the context.xml defaults with the way web.xml
is processed (remm)
-context.xml should be a redeploy resource, and add prioritization for
redeploy resources. (remm)

These don't seem to be related to my situation.

In further reading the Tomcat documentation, I find
(http://tomcat.apache.org/tomcat-5.5-doc/config/context.html):

"Please note that for tomcat 5, unlike tomcat 4.x, it is NOT
recommended to place <Context> elements directly in the server.xml
file."

Then later it says:

"If you specify a context path of an empty string (""), you are
defining the default web application for this Host, which will process
all requests not assigned to other Contexts. The value of this field
must not be set except when statically defining a Context in
server.xml, as it will be infered from the filenames used for either
the .xml context file or the docBase."

...and it also says:

"In addition, you MUST define a Context with a context path equal to a
zero-length string."

So I'm not sure what the correct thing to do is.  I am told NOT to put
context elements in the server.xml file, then I am told that I should
define contexts with an empty string in the server.xml file, and then
I am told that I must define a context with a zero-length string. 
This information is contradictory, so I'm not sure what the correct
course of action is.

So, to sum it up:

How do I set up a default context in 5.5.12 for a web application that
is not located in the web apps directory (I could do this for 5.5.7
and before using the method described above).

Thanks for any help you can offer.

Jason

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org