You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Claudio Tassini <cl...@gmail.com> on 2008/09/05 10:11:59 UTC

symlinks in webapps

Hi guys,
I'm trying to make a link to an app inside the webapps directory in tomcat
6.0.18 . The goal is to have the same webapp referenced by two contexts, and
this worked fine in 5.x . In 6.x, if I make a symlink to a webapp in the
webapps directory, the app fails to start:

[root@portal1 webapps]# ln -s WebMail WebMail2
[root@portal1 webapps]# ls -l
total 24
drwxr-xr-x  11 mwtomcat mwtomcat 4096 Sep  3 10:57 docs
drwxr-xr-x   5 mwtomcat mwtomcat 4096 Sep  3 10:57 examples
drwxr-xr-x   5 mwtomcat mwtomcat 4096 Sep  3 10:57 host-manager
drwxr-xr-x   5 mwtomcat mwtomcat 4096 Sep  3 10:57 manager
drwxr-xr-x   3 mwtomcat mwtomcat 4096 Sep  3 10:57 ROOT
drwxr-xr-x   6 mwtomcat mwtomcat 4096 Aug 28 15:32 WebMail
lrwxrwxrwx   1 root     root        7 Sep  5 10:06 WebMail2 -> WebMail

Sep 5, 2008 10:07:07 AM org.apache.catalina.core.StandardContext start
SEVERE: Error filterStart
Sep 5, 2008 10:07:07 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/WebMail] startup failed due to previous errors

I've tried to add the allowLinking property in context.xml (in the default
conf/context.xml and in the META-INF/context.xml of my webapp... just to be
sure), but it don't work. I guess that allowLinking allows to make links
from inside the context to other places in the filesystem, not to link the
context itself to another webapp.
I found this very useful in tests environment. Is there a way to achieve
this in tomcat 6?

-- 
Claudio Tassini

Re: symlinks in webapps

Posted by Claudio Tassini <cl...@gmail.com>.
> I don't think that's true - each directory or .war file in the appBase
> directory will cause a separate application deployment, which is what I
> thought you wanted.


As you may have noted, I am not a Tomcat expert so you are probably right.
But my app logs in catalina.out when it reads its config files, and when I
made a symlink in webapps/ to the same webapp it happened just once, while
if I create more contexts blocks in server.xml it loads as many times as are
the "instances". Another evidence is that the app create a connection pool
of 10 connections to an LDAP server, and with the server just started I have
exactly 20 established connections , while I was used to only 10 with the
old "method".

1) Implement a valve or filter that catches references to the alternate URLs
> and redirects or forwards them to the primary.
>
I am going to study how to accomplish this. Will let you know.


>
> 2) Create dummy webapps for the alternate URLs that contain nothing but an
> index.html page that redirects to the primary.
>
This does not sound really "clean" :) I will keep it as last resort...


-- 
Claudio Tassini

RE: symlinks in webapps

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Claudio Tassini [mailto:claudio.tassini@gmail.com]
> Subject: Re: symlinks in webapps
>
> it causes my app to start several times, while with
> a simple symlink I had the same webapp referenced as
> many times as I wished

I don't think that's true - each directory or .war file in the appBase directory will cause a separate application deployment, which is what I thought you wanted.  If what you really want is just to have multiple URLs refer to the same (single) webapp, you have a couple of fairly easy choices:

1) Implement a valve or filter that catches references to the alternate URLs and redirects or forwards them to the primary.

2) Create dummy webapps for the alternate URLs that contain nothing but an index.html page that redirects to the primary.

 - 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 start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: symlinks in webapps

Posted by Claudio Tassini <cl...@gmail.com>.
>
>
> The second context xml file, named secondInstance.xml (URL would be
> http://localhost:8080/secondInstance):
> <Context docBase="originalWebapp"> <!-- Define second instance resources if
> any --> </Context>
>

This don't work. It seems that with tomcat > 5.0 you can't point a context's
docBase to something INSIDE the appBase directory when using context files
in conf/[Engine name]/[Host name]/[context].xml . You must add them to
server.xml, which is discouraged.

-- 
Claudio Tassini

Re: symlinks in webapps

Posted by David Smith <dn...@cornell.edu>.
Of course you *could* do something to encourage a double deploy and get 
the desired result.  Just make a context xml file named after the second 
context path and set it's docbase to point to the original webapp's 
folder.  It'd look something like this:

Assuming you have this in your conf/[Engine name]/[Host name] directory 
for the original webapp in webapps/originalWebapp (URL would be 
http://localhost:8080/originalWebapp):

originalWebapp.xml:
<Context >   <!-- Define resources here --> </Context>

The second context xml file, named secondInstance.xml (URL would be 
http://localhost:8080/secondInstance):
<Context docBase="originalWebapp"> <!-- Define second instance resources 
if any --> </Context>

That should deploy the webapp a second time.  Most developers try to 
avoid that, but you seem to be looking for exactly this kind of thing.

--David

Claudio Tassini wrote:
> FYI, If I add several <Context docBase="WebMail" path="/xxxx" /> blocks each
> with a different path , in my server.xml, it seems to work . The problem is
> that it's discouraged in tomcat's documentation, and anyway it causes my app
> to start several times, while with a simple symlink I had the same webapp
> referenced as many times as I wished without multiplying the load on the
> server (the app starts ldap pools... db pools and so on...).
> On Sat, Sep 6, 2008 at 6:34 PM, Claudio Tassini
> <cl...@gmail.com>wrote:
>
>   
>> Don't seem to work. It seems that I can't use a docBase in a context.xml
>> that points to something under the appBase directory, as it's simply ignored
>> and tomcat assumes that the docbase is in /webapps :
>> Sep 6, 2008 6:23:28 PM org.apache.catalina.startup.HostConfig
>> deployDescriptor
>> WARNING: A docBase /opt/webmail-portal-tomcat/webapps/WebMail inside the
>> host appBase has been specified, and will be ignored
>> Sep 6, 2008 6:23:28 PM org.apache.catalina.core.StandardContext
>> resourcesStart
>> SEVERE: Error starting static Resources
>> java.lang.IllegalArgumentException: Document base
>> /opt/webmail-portal-tomcat/webapps/WebMail2 does not exist or is not a
>> readable directory
>>
>>
>> On Fri, Sep 5, 2008 at 9:05 PM, Caldarale, Charles R <
>> Chuck.Caldarale@unisys.com> wrote:
>>
>>     
>>>> From: Claudio Tassini [mailto:claudio.tassini@gmail.com]
>>>> Subject: symlinks in webapps
>>>>
>>>> The goal is to have the same webapp referenced by
>>>> two contexts
>>>>         
>>> Rather than use symlinks, try using an additional <Context> element in
>>> conf/Catalina/[host]/WebMail2.xml:
>>>
>>> <Context docBase="WebMail" />
>>>
>>> (Include whatever else is needed from the META-INF/context.xml file, if
>>> there is one.  Do NOT use a path attribute.)
>>>
>>> Haven't tried this exact situation, but I think it should work... (famous
>>> last words).
>>>
>>>  - 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 start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>       
>> --
>> Claudio Tassini
>>
>>     


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


Re: symlinks in webapps

Posted by Claudio Tassini <cl...@gmail.com>.
FYI, If I add several <Context docBase="WebMail" path="/xxxx" /> blocks each
with a different path , in my server.xml, it seems to work . The problem is
that it's discouraged in tomcat's documentation, and anyway it causes my app
to start several times, while with a simple symlink I had the same webapp
referenced as many times as I wished without multiplying the load on the
server (the app starts ldap pools... db pools and so on...).
On Sat, Sep 6, 2008 at 6:34 PM, Claudio Tassini
<cl...@gmail.com>wrote:

> Don't seem to work. It seems that I can't use a docBase in a context.xml
> that points to something under the appBase directory, as it's simply ignored
> and tomcat assumes that the docbase is in /webapps :
> Sep 6, 2008 6:23:28 PM org.apache.catalina.startup.HostConfig
> deployDescriptor
> WARNING: A docBase /opt/webmail-portal-tomcat/webapps/WebMail inside the
> host appBase has been specified, and will be ignored
> Sep 6, 2008 6:23:28 PM org.apache.catalina.core.StandardContext
> resourcesStart
> SEVERE: Error starting static Resources
> java.lang.IllegalArgumentException: Document base
> /opt/webmail-portal-tomcat/webapps/WebMail2 does not exist or is not a
> readable directory
>
>
> On Fri, Sep 5, 2008 at 9:05 PM, Caldarale, Charles R <
> Chuck.Caldarale@unisys.com> wrote:
>
>> > From: Claudio Tassini [mailto:claudio.tassini@gmail.com]
>> > Subject: symlinks in webapps
>> >
>> > The goal is to have the same webapp referenced by
>> > two contexts
>>
>> Rather than use symlinks, try using an additional <Context> element in
>> conf/Catalina/[host]/WebMail2.xml:
>>
>> <Context docBase="WebMail" />
>>
>> (Include whatever else is needed from the META-INF/context.xml file, if
>> there is one.  Do NOT use a path attribute.)
>>
>> Haven't tried this exact situation, but I think it should work... (famous
>> last words).
>>
>>  - 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 start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
>
> --
> Claudio Tassini
>



-- 
Claudio Tassini

Re: symlinks in webapps

Posted by Claudio Tassini <cl...@gmail.com>.
Don't seem to work. It seems that I can't use a docBase in a context.xml
that points to something under the appBase directory, as it's simply ignored
and tomcat assumes that the docbase is in /webapps :
Sep 6, 2008 6:23:28 PM org.apache.catalina.startup.HostConfig
deployDescriptor
WARNING: A docBase /opt/webmail-portal-tomcat/webapps/WebMail inside the
host appBase has been specified, and will be ignored
Sep 6, 2008 6:23:28 PM org.apache.catalina.core.StandardContext
resourcesStart
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base
/opt/webmail-portal-tomcat/webapps/WebMail2 does not exist or is not a
readable directory


On Fri, Sep 5, 2008 at 9:05 PM, Caldarale, Charles R <
Chuck.Caldarale@unisys.com> wrote:

> > From: Claudio Tassini [mailto:claudio.tassini@gmail.com]
> > Subject: symlinks in webapps
> >
> > The goal is to have the same webapp referenced by
> > two contexts
>
> Rather than use symlinks, try using an additional <Context> element in
> conf/Catalina/[host]/WebMail2.xml:
>
> <Context docBase="WebMail" />
>
> (Include whatever else is needed from the META-INF/context.xml file, if
> there is one.  Do NOT use a path attribute.)
>
> Haven't tried this exact situation, but I think it should work... (famous
> last words).
>
>  - 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 start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
Claudio Tassini

RE: symlinks in webapps

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Claudio Tassini [mailto:claudio.tassini@gmail.com]
> Subject: symlinks in webapps
>
> The goal is to have the same webapp referenced by
> two contexts

Rather than use symlinks, try using an additional <Context> element in conf/Catalina/[host]/WebMail2.xml:

<Context docBase="WebMail" />

(Include whatever else is needed from the META-INF/context.xml file, if there is one.  Do NOT use a path attribute.)

Haven't tried this exact situation, but I think it should work... (famous last words).

 - 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 start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org