File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Need help with multiple contexts for a webapp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Need help with multiple contexts for a webapp" Watch "Need help with multiple contexts for a webapp" New topic

Need help with multiple contexts for a webapp

Jeremy Muchler

Joined: Sep 09, 2011
Posts: 1
I've been trying to get multiple context names to link to a single webapp (without running multiple copies of the application itself).

I have a deployed webapp running on a Tomcat server. If you go to the URL, it works (which is great). Say the URL is What we are trying to do is to be able to have run the webapp and keep a reference to the custom url (so that all the pages will have etc in the address bar). Total we will have at least a dozen different names pointing at the same web app. Because the application itself is rather memory intensive, we are trying to avoid running multiple copies of the app. Because of decisions from the marketing team, we can't use sub-domains of the name so I haven't investigated using virtual hosts.

I was able to setup the contexts so that they work by adding them to the server.xml file, but I ran into issues with the web app trying to cache itself four times (three contexts, plus the "real" name) which would cause the server to grind to a halt and the catalina.out to throw tons of errors. I have tried to setup context files in /webapps/ and in the Meta-INF folder of the webapp itself, but either the web app would fail to load because of a malformed context file, or in the catalina logs i would see where the entries were being ignored (due to setting a path that is already within the app path).

I am not opposed to putting in the work to setup Apache+Tomcat if necessary. We haven't done so to date because this web server only runs the webapp and nothing else.

Any ideas on how to get this craziness to work?
I agree. Here's the link:
subject: Need help with multiple contexts for a webapp
It's not a secret anymore!