Tomcat: using webapp context to override default URL

S

sugnaboris

Hope someone can help with a config problem I'm having. Many thanks in
advance for at least taking a look.

I'm building a WAR using Netbeans 5.5.1. The WAR takes its name from
the project root directory, so I end up with MyProjectRoot.war. I drop
this into the webapps folder under Tomcat 5.5, and it gets expanded
out into a directory of its own called MyProjectRoot. This has a META-
INF directory, containing a context.xml file, which has the following
contents:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/MyURL"/>

in other words, I want to be able to access the webapp using:

http://<server>:8080/MyURL

However, I can only access the webapp at:

http://<server>:8080/MyProjectRoot

I've noticed that a new file has been generated in the directory:

Tomcat 5.5\conf\Catalina\localhost

This is called MyProjectRoot.xml, and has the following contents:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/MyURL"/>

At the moment, I can work around by renaming the WAR prior to
deployment; but this should ideally be configurable.

Can anyone advise on how I can use the webapp configuration to force
the URL that I want? I thought the context.xml contents would do that:
it seems to work OK with the NetBeans bundled Tomcat during
development - although the webapp then lives outside the Tomcat
hierarchy.

Thanks again to all who read this far, and especially to anyone who
can advise on how to achieve this!

Ron
 
S

sugnaboris

The trick is to put just a .xml file under conf/Catalina/localhost/

Try something like:

<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/export/zfs/marcelo/mypath/MyProjectRoot" path="/
MyUrl"/>

and put the exploded app under /export/zfs/marcelo/mypath/
MyProjectRoot/

Seehttp://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html

Thanks, Marcelo - I'll give it a go and let you know what happens. I
see that's for 6.0, but maybe it's the same deal with 5.5. I already
have an automatically-generated file in that location, named after the
webapp - is the filename important?
Hope it helps

Don't we all! ;-)
 
M

Marcelo Morales

Thanks, Marcelo - I'll give it a go and let you know what happens. I
see that's for 6.0, but maybe it's the same deal with 5.5. I already
have an automatically-generated file in that location, named after the
webapp - is the filename important?


Don't we all! ;-)

AFAICT, the filename is important. It shouldn't be, though. I think I
remember reading about it on the page which link I already sent you.

Have fun finding out

Marcelo Morales
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top