tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Flynn <>
Subject Re: Multiple applications
Date Wed, 29 Jul 2009 10:33:02 GMT
Hassan Schroeder wrote:
> On Tue, Jun 23, 2009 at 7:37 AM, Peter Flynn <> wrote:
>> I've been using Tomcat5 with Apache2 under RH5 to run Cocoon, but I
>> now need to add Lucene and eXist. Is it possible to run multiple
>> applications like this on the same machine using the same Tomcat
>> server?
> Yes.

I only get a short time per month to look at this stuff so my apologies 
for not getting back sooner.

>> At the moment, all Cocoon pages get an extra "cocoon/" token
>> inserted in their URI, eg http://myhost.server.domain/cocoon/stuff.
>> I did look at just replacing ROOT in webapps but that seems a
>> little heavy-handed,
> Renaming a directory (or war file) is "heavy-handed"???

I would have thought so -- with an outsider's eyes. One doesn't normally 
want to mess with the default directory layout of installed software, 
only add to it and edit configs. I don't know what the default ROOT 
actually does.

>> and it would seem to defeat any chance of adding Lucene and eXist.
> No it wouldn't.

Excellent, thanks.

> Look at the examples that come with the standard distro. It should be
> apparent that (and how) multiple webapps are supported.

...and Caldarale, Charles R wrote:
 > Clearly you can - look how many independent webapps are deployed in
 > the standard Tomcat download.

Unfortunately that is opaque to me. This is /var/lib/tomcat5 (under RHEL4):

   drwxr-x---  5 root   tomcat     4096 Feb 27  2008 balancer
   drwxr-xr-x  9 tomcat tomcat     4096 Apr 21 12:00 cocoon
   drwxrwxr-x 21 root   tomcat     4096 Apr  7  2008 jsp-examples
   drwxrwxr-x  4 root   tomcat     4096 Apr  7  2008 ROOT
   drwxrwxr-x  4 root   tomcat     4096 Apr  7  2008 servlets-examples
   drwxrwxr-x 12 root   tomcat     4096 Apr  7  2008 tomcat-docs
   drwxrwxr-x  3 root   tomcat     4096 Apr  7  2008 webdav

Apart from cocoon, which I added, I am not aware of what balancer is or 
what I might want it for. I can see examples, and tomcat-docs, and I 
know what webdav is (although I don't use it). But these look to me like 
utilities that come with Tomcat, rather than "apps". No matter, if apps 
they are, that's fine.

Caldarale, Charles R wrote:
> Replacing ROOT with your desired default webapp for the domain is not
> heavy-handed, it's expected.


> You can obviously only have one default webapp per <Host>; other
> webapps for the <Host> have to be explicitly named.

Yes, but where does this explicit naming take place? server.xml? web.xml?

I currently have a Host element type in server.xml naming the host 
(which is a cname; this is all front-ended by Apache with a VH):

<Host name="" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
<!-- default application is Cocoon -->
   <Context path="" docBase="/var/www/xml/"
            debug="9" crossContext="true"/>
<!-- anything with a slash is also the default -->
   <Context path="/" docBase="/var/www/xml/"
            debug="9" crossContext="true"/>

This is currently all working and is correctly 
bringing up my Cocoon pages.

>> Is there another way to get rid of the "cocoon/", because the
>> Cocoon pages will be the interface the user sees (but somehow
>> preserve an equivalent "lucene/" and "eXist/" because they won't be
>> seen much)?
> Rename your Cocoon webapp to ROOT (remove the old ROOT first), and
 > install your Lucene and eXist applications under whatever names you
 > choose under the <Host> appBase directory.

Leave Lucene and eXist aside for the moment. I renamed ROOT to OLDROOT 
and renamed the cocoon directory to ROOT. Restarted tomcat and apache. 
But when I tried I got a Tomcat 404

    The requested resource (/cocoon) is not available.

Somewhere it's not looking in the right place. What other changes are 
needed to make it pick up the app that is in the ROOT directory?

(I've renamed them all back the way they were for the moment.)

> You likely only have one <Host>, and if you haven't changed the
 > default appBase setting, it's the webapps directory.


 > Your structure should look like this:
 >   webapps
 >     ROOT (containing your Cocoon webapp)
 >     lucene (containing your Lucene webapp)
 >     exist (containing your eXist webapp)

Yes, although lucene and exist aren't there yet, and there is the other 
default stuff in webapps as shown in the listing above.)

> The names are case-sensitive, so choose them carefully; they can be
 > anything you choose, other than ROOT.

I'm still trying to get it to serve cocoon when I move the default ROOT 
out of the way and rename the cocoon directory to ROOT, but there is 
obviously some other key piece of information I am missing here.

David Smith wrote:
> You can name your cocoon webapp ROOT and then add lucene and eXist 
> webapps. If lucene or eXist webapps exist, the request will go to 
> them. It'll only hit ROOT if those webapps aren't there or running. 
> This falls under the requirement of servlet containers to make the 
> longest match at each stage of the decision making process. When 
> choosing which webapp, the longest match is used and then again at
> the servlet mapping level, the longest match takes it.

That makes sense, except that simply renaming cocoon to ROOT just gets 
me the 404 "requested resource (/cocoon) is not available" message. 
There must be some other change (to a config file?). The only changes I 
have made to the default config are to add the hostname to server.xml as 
above and comment out the servlet-mapping for Cocoon in web.xml (if it 
is left in, all requests to the server for cocoon pages get a 503 
Service Temporarily Unavailable). I don't know why that should be.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message