| Author |
Configuring a context outside of $CATALINA_HOME/webapps
|
deb platt
Ranch Hand
Joined: Jan 23, 2008
Posts: 44
|
|
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
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Three things. Does your testcontext directory have a WEB-INF directory inside it? If not, add it (spelling is case sensitive so be sure to type in in all upper case). Try fully qualifying the docBase attribute. docBase="c:\testcontext". Where are you putting testcontext.xml? [ June 23, 2008: Message edited by: Ben Souther ]
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
deb platt
Ranch Hand
Joined: Jan 23, 2008
Posts: 44
|
|
First to answer your question, testcontext.xml is located in $CATALINA_HOME/conf/Catalina/localhost/. The expanded path on my machine is C:\Apps\Tomcat_6.0\conf\Catalina\localhost\testcontext.xml Previously my entire context was one directory (/testcontext) holding one file (index.html). After reading your post, I created the subdirectory /textcontext/WEB-INF. When I restarted tomcat, the catalina log reported the same errors and I got a 404 when I attempted to access index.html via my browser. Next I tried changing the contents of testcontext.xml to be the following: <Context docBase="C:\testcontext" /> When I restarted tomcat, I was delighted that no errors were reported in the catalina log. When I attempted to access index.html via the URL http://localhost:8080/testcontext/index.html the page appeared in my browser as I had hoped. I thank you for your help! I had wanted to try doing this on my laptop before trying it on our Solaris server. For a UNIX-like OS, I am assuming that that I would change textcontext.xml as follows: <Context docBase="/testcontext" /> Deb
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Yes. That's how I do it on my Linux workstation.
|
 |
 |
|
|
subject: Configuring a context outside of $CATALINA_HOME/webapps
|
|
|