Originally posted by Ben Souther at why .war file in webapps folder only...:
The webapps directory is the the default place to put web apps but it's far from the only place you can put them....You can configure the docbase to point to any directory on your system that Tomcat can see.
For more details, see:
http://tomcat.apache.org/tomcat-6.0-doc/config/index.html
I am apparently having some difficulties following the above documentation. Here's what I'm trying to do on my windows machine. For the most part, I want
tomcat to behave in the default way, serving up contexts under the webapps directory. However, I'd also like to serve up documents in one directory outside of webapps. So to do a
test run of this, I created a file, "C:\testcontext\index.html". On the same machine, I attempted to create a context description, named "testcontext.xml". Here are it's contents:
Next I had to decide where to put it. Since I only wanted one context to behave in a non-default way, the documentation seemed to suggest that there was only one place for me to put the xml file:
$CATALINA_HOME/conf/[enginename]/[hostname]/ . So I interpreted this as meaning I should put testcontext.xml in $CATALINA_HOME/conf/Catalina/localhost/. I stopped and restarted Tomcat. I then entered the URL for the default webapp (
http://localhost:8080) -- that worked fine. Next I tried entering the URL testcontext (
http://localhost:8080/testcontext/index.html). That resulted in a 404. I went and checked the catalina log and it said:
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base C:\Apps\Tomcat_6.0\webapps\testcontext does not exist or is not a readable directory ... INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/testcontext] has not been started
At this point I'm looking around some more and I run into documentation that says for me to not set the path attribute, as this will be inferred. So I remove that from testcontext.xml, so it's contents are now:
However I still get a 404 and the log still reports the same error.
I then wonder if the direction of the slash makes a difference, and I change the value of docBase to be "/testcontext" with the same results.
I'm apparently misunderstanding the documentation. Any guidance would be appreciated.
Deb