Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2008

Tip: Looking for answers? Try searching our database.

Tomcat: using webapp context to override default URL

Thread view: 
sugnaboris@gmail.com - 05 Mar 2008 13:24 GMT
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
Marcelo Morales - 05 Mar 2008 17:41 GMT
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/

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

Hope it helps
sugnaboris@gmail.com - 06 Mar 2008 08:32 GMT
On 5 Mar, 17:41, Marcelo Morales <marcelomorales.n...@gmail.com>
wrote:
> The trick is to put just a .xml file under conf/Catalina/localhost/
>
[quoted text clipped - 8 lines]
>
> 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! ;-)
Marcelo Morales - 06 Mar 2008 20:09 GMT
On Mar 6, 4:32 am, sugnabo...@gmail.com wrote:
> On 5 Mar, 17:41, Marcelo Morales <marcelomorales.n...@gmail.com>
> wrote:
[quoted text clipped - 20 lines]
>
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.