You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by rm...@hire.com on 2003/08/26 21:03:11 UTC

classpath error when changing context

My web app is up and running, but when I added a context definition (<Context.../>) for it suddenly the jsp compiler can't find the classes in WEB-INF/classes.  What gives?

My jsp files are in a subdirectory of the web app, like such: $CATALINA_HOME/webapps/foo/bar/index.jsp.  I added an xml file to the web apps directory to add the context definition so instead of hitting url http://localhost:8080/foo/bar/index.jsp I could just hit http://localhost:8080/bar/index.jsp.  The context definition is like:

<Context path="/bar" docBase="foo/bar" reloadable="false"/>

But when I use that new url, the compiler complains about not being able to find the classes (in WEB-INF/classes).  If I hit the original url, it works fine.

Thanks!

Re: classpath error when changing context

Posted by Christopher Garrett <mi...@inixoma.com>.
What is your appBase defined as in <Host>?
In what directory is your WEB-INF located? $CATALINA_HOME/webapps or
$CATALINA_HOME/webapps/foo/bar?

I'm guessing your WEB-INF is located in $CATALINA_HOME/webapps[/WEB-INF/], and
that your appBase is probably "webapps". When you access
http://localhost:8080/foo/bar/index.jsp, there is no specific <Context> matching
this, so Tomcat defaults to using the webapps context [$CATALINA_HOME/webapps/],
in which WEB-INF is probably located [$CATALINA_HOME/webapps/WEB-INF/]. The
proper classes/libs are then able to be loaded without any problems, and the
index.jsp is found two directories down from $CATALINA_HOME/webapps in
$CATALINA_HOME/webapps/foo/bar/, as the URI suggests.

In the case of a request to http://localhost:8080/bar/index.jsp, there happens
to be a <Context> defined matching the URI "/bar"; however, you've given this a
context of "foo/bar", which has the absolute path
$CATALINA_HOME/webapps/foo/bar/ [again, assuming your appBase has been set to
"webapps"]. So, Tomcat is going to then look for WEB-INF inside the context
you've told it describes this web application, i.e.
$CATALINA_HOME/webapps/foo/bar/WEB-INF/.

I believe this is the problem, though I may be incorrect.

Christopher Garrett III
Inixoma, Incorporated

----- Original Message -----
From: <rm...@hire.com>
To: <to...@jakarta.apache.org>
Sent: Tuesday, August 26, 2003 3:03 PM
Subject: classpath error when changing context


My web app is up and running, but when I added a context definition
(<Context.../>) for it suddenly the jsp compiler can't find the classes in
WEB-INF/classes.  What gives?

My jsp files are in a subdirectory of the web app, like such:
$CATALINA_HOME/webapps/foo/bar/index.jsp.  I added an xml file to the web apps
directory to add the context definition so instead of hitting url
http://localhost:8080/foo/bar/index.jsp I could just hit
http://localhost:8080/bar/index.jsp.  The context definition is like:

<Context path="/bar" docBase="foo/bar" reloadable="false"/>

But when I use that new url, the compiler complains about not being able to find
the classes (in WEB-INF/classes).  If I hit the original url, it works fine.