You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mark Leone <mi...@verizon.net> on 2011/06/10 05:15:00 UTC

Context Definition Doesn't Work

I've been running Tomcat since version 4. Today, running 7.0.12,  I 
decided to define a non-standard context, and I can't get it to work 
after carefully following all the instructions in the documentation and 
doing what all my searching confirmed I should be doing.

My web app is deployed at $CATALINA_HOME/webapps/filePort. I've been 
reaching it at http://myHost/filePort. Now I want to have a context of 
/mbp/filePort, because I want the web app to run on three separate 
Tomcat instances behind an apache server, using mod_jk to route to each 
Tomcat based on the first part of the context path.

So I have the file 
$CATALINA_HOME/conf/Catalina/localhost/mbp#filePort.xml, and inside this 
file is the following XML

<Context >
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>

In server.xml I have Engine "Catalina" and Host "localhost" defined, 
with no Context defined. I have no Context defined anywhere else. The 
appBase for Host "localhost" is defined as "webapps".

However, the web app is still reachable at http://myHost/filePort and 
not at http://myHost/mbp/filePort. For the latter URL, Tomcat reports 
that the requested resource is not available.

Even though it's not recommended, I tried defining a Context element in 
server.xml, inside the Host element, with path="/mbp/filePort" and 
docBase="filePort" but I got the same result.

Presumably I'm missing something here, but I've done what the 
documentation says to do, and it doesn't work.

-Mark

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


Re: [OT] Context Definition Doesn't Work

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chuck,

On 6/10/2011 12:33 AM, Caldarale, Charles R wrote:
> $CATALINA_HOME/webapps/mbp#filePort

FWIW, path names containing a # symbol can wreak havoc on certain APIs
that use URLs to locate resources.

Case in point: Apache Cocoon uses file: URLs to locate files on the
disk. Since the path contains a "#", it is determined to be illegal
because # isn't a valid character in a URL. "No problem", you say, and
change that to "%23" and all will be well. Yes and no. Evidently, Cocoon
specifically decodes the URL one or more times and by the tine it gets
to the component that tries to use it, it's a "#" no matter what you try
to do :(

If you find yourself having similar problems with mbp#filePort as your
deployment directory, you can always have the deployment descriptor
mbp#filePort.xml point to a directory somewhere *outside* Tomcat's
webapps directory and you should avoid that headache.

You will probably never have this problem, but I suffered through it
myself and seek to help others avoid it, or at least understand it.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3yf+EACgkQ9CaO5/Lv0PBp2ACfXvB/uvZHh32MgmnwCYwtq2oq
SR0AoJXKhDGlfftq6AZ+aBqxbNehDauD
=JQjg
-----END PGP SIGNATURE-----

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


RE: Context Definition Doesn't Work

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Mark Leone [mailto:midnightjava@verizon.net] 
> Subject: Context Definition Doesn't Work

> My web app is deployed at $CATALINA_HOME/webapps/filePort.

That's the problem; see below.

> So I have the file 
> $CATALINA_HOME/conf/Catalina/localhost/mbp#filePort.xml

And I suspect that if you look in the logs, you'll see there are errors trying to deploy this non-existent webapp.

> <Context >
> <WatchedResource>WEB-INF/web.xml</WatchedResource>
> </Context>

The above <Context> is unnecessary, since that's the default.  Unless you're planning on adding something else in there, you can remove the file.

> the web app is still reachable at http://myHost/filePort

Because that's where it's located.  Change the location of the webapp to:

$CATALINA_HOME/webapps/mbp#filePort

> Even though it's not recommended, I tried defining a Context element in 
> server.xml, inside the Host element, with path="/mbp/filePort" and 
> docBase="filePort" but I got the same result.

Good, because that was a bad idea, presumably done as an act of desperation.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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