You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Vivek Mohan <vi...@gmail.com> on 2005/11/30 12:02:16 UTC

How to deploy my webapp as root context webapp without tomcat loading it twice?

Hi,

Scenario:

I've a webapplication in my tomcat4 installation, called myWebapp.
I've configured it to be my root webapplication since I want users to
be able to access it using the url: "http:<host>:<port>". Here's a
snippet of my server.xml:

<!-- Define the default virtual host -->
<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true"
autoDeploy="false" liveDeploy="false">

 <!-- Tomcat Root Context -->
       <Context path="" docBase="myWebapp" debug="0" reloadable="true">
         <Logger className="org.apache.catalina.logger.FileLogger"
                    prefix="localhost_myWebapp_log." suffix=".txt"
          timestamp="true"/>
</Context>

myWebapp has a init servlet which is loaded on startup. Besides doing
other things like instantiating db connection pool, this servlet
configures the log4j for the application logging.

Issue:

When I start the tomcat server, I find, through logs of the application (and
of log4j), that the init servlet is executed twice.
Essentially, the webapp is loaded twice. This creates a problem with
myWebapp since the logger is configured twice (resulting in
cross-locks and hence Rolling fails).

Question:

I want to have myWebapp as the root context webapp in my tomcat
server. And I don't want to rename it to "ROOT". Is there a way by
which I can avoid tomcat from loading myWebapp twice?

Thanks in advance,
Vivek.

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


Re: How to deploy my webapp as root context webapp without tomcat loading it twice?

Posted by Vivek Mohan <vi...@gmail.com>.
Sorry Mark, but one question to you since you've suggested the option
of moving the webapp outside of appBase.

I've kept myWebapp at ${CATALINA.HOME}/myWebapp and given this path in
server.xml for the root context. Is that the correct way to do it? Is
there anything in my webapp that I need to take care of when I do
this?

--
Vivek.

On 12/1/05, Mark Thomas <ma...@apache.org> wrote:
> Vivek Mohan wrote:
> > Question:
> >
> > I want to have myWebapp as the root context webapp in my tomcat
> > server. And I don't want to rename it to "ROOT". Is there a way by
> > which I can avoid tomcat from loading myWebapp twice?
>
> Options:
> - Don't put it in the appbase directory.
> - Turn off autoDeploy
> - Live with renaming it to ROOT
>
> Mark
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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


Re: How to deploy my webapp as root context webapp without tomcat loading it twice?

Posted by Francis Galiegue <fg...@gmail.com>.
2005/12/1, Paul Singleton <pa...@jbgb.com>:
> Vivek Mohan wrote:
> > Like I mentioned in my problem statement:
> >
> > I don't want to move my application into ROOT folder or rename it to ROOT.
> > And unlike as you said Mark, putting autoDeploy=false doesn't help in this case.
> >
> > Is this (loading a webapp twice if the context path and the docBase
> > path is different) a feature of Tomcat? Can't this be turned off?
>
> My hunch is that you won't get a definitive answer to this question
> in this group :-/
>
> I *think* you need to do all these:
>
>  * maintain an empty appBase directory
>
>  * leave autoDeploy alone (there's nothing for it to deploy)
>
>  * set docBase in Context to an absolute path to your app
>

That's what I did, I submitted this problem a month ago or so and came
up with this solution, asking if there weren't any better ones.
Renaming the webapp dir to ROOT is a nono so far, so I defined a
nonexisting appBase and put an absolute path in <Context>. It works,
but it's ugly, for sure :(

I wonder whether creating Catalina/<hostname here>/ROOT.xml with the
appropriate <Context> would work...

(BTW this is using tomcat 5.0.x, x>=27)


--
Francis Galiegue, fgaliegue@gmail.com, fg@one2team.com, fg6@wanadoo.fr
One2team - 12bis rue de la Pierre Levée, 75011 Paris - 0143381980
"When it comes to performance, weight is everything" - Tiff Needell

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


Re: How to deploy my webapp as root context webapp without tomcat loading it twice?

Posted by Paul Singleton <pa...@jbgb.com>.
Vivek Mohan wrote:
> Like I mentioned in my problem statement:
> 
> I don't want to move my application into ROOT folder or rename it to ROOT.
> And unlike as you said Mark, putting autoDeploy=false doesn't help in this case.
> 
> Is this (loading a webapp twice if the context path and the docBase
> path is different) a feature of Tomcat? Can't this be turned off?

My hunch is that you won't get a definitive answer to this question
in this group :-/

I *think* you need to do all these:

 * maintain an empty appBase directory

 * leave autoDeploy alone (there's nothing for it to deploy)

 * set docBase in Context to an absolute path to your app

regards

Paul Singleton


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.362 / Virus Database: 267.13.10/189 - Release Date: 30/Nov/2005


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


Re: How to deploy my webapp as root context webapp without tomcat loading it twice?

Posted by Vivek Mohan <vi...@gmail.com>.
Like I mentioned in my problem statement:

I don't want to move my application into ROOT folder or rename it to ROOT.
And unlike as you said Mark, putting autoDeploy=false doesn't help in this case.

Is this (loading a webapp twice if the context path and the docBase
path is different) a feature of Tomcat? Can't this be turned off?

--
Vivek.

On 12/1/05, Joe Riopel <go...@gmail.com> wrote:
> Since this was brought up..
>
> I moved my default ROOT folder out my webapps directory ( to a temp
> dir on my server ), because I wanted a different app to the be the
> default application. So I moved my application's direcotry to
> webapps/ROOT and everything has been working fine. Is there anything
> "wrong" with doing it that way ? Like I said, everything has been
> working great so far, which has been about 3 months.
>
> Thanks,
> Joe
>
> On 11/30/05, Mark Thomas <ma...@apache.org> wrote:
> > Vivek Mohan wrote:
> > > Question:
> > >
> > > I want to have myWebapp as the root context webapp in my tomcat
> > > server. And I don't want to rename it to "ROOT". Is there a way by
> > > which I can avoid tomcat from loading myWebapp twice?
> >
> > Options:
> > - Don't put it in the appbase directory.
> > - Turn off autoDeploy
> > - Live with renaming it to ROOT
> >
> > Mark
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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


Re: How to deploy my webapp as root context webapp without tomcat loading it twice?

Posted by Joe Riopel <go...@gmail.com>.
Since this was brought up..

I moved my default ROOT folder out my webapps directory ( to a temp
dir on my server ), because I wanted a different app to the be the
default application. So I moved my application's direcotry to
webapps/ROOT and everything has been working fine. Is there anything
"wrong" with doing it that way ? Like I said, everything has been
working great so far, which has been about 3 months.

Thanks,
Joe

On 11/30/05, Mark Thomas <ma...@apache.org> wrote:
> Vivek Mohan wrote:
> > Question:
> >
> > I want to have myWebapp as the root context webapp in my tomcat
> > server. And I don't want to rename it to "ROOT". Is there a way by
> > which I can avoid tomcat from loading myWebapp twice?
>
> Options:
> - Don't put it in the appbase directory.
> - Turn off autoDeploy
> - Live with renaming it to ROOT
>
> Mark
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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


Re: How to deploy my webapp as root context webapp without tomcat loading it twice?

Posted by Mark Thomas <ma...@apache.org>.
Vivek Mohan wrote:
> Question:
> 
> I want to have myWebapp as the root context webapp in my tomcat
> server. And I don't want to rename it to "ROOT". Is there a way by
> which I can avoid tomcat from loading myWebapp twice?

Options:
- Don't put it in the appbase directory.
- Turn off autoDeploy
- Live with renaming it to ROOT

Mark


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