5

I'm using apache 2 and tomcat 7 to run my webapps..

When I start Tomcat, its log shows that the same webapp has deployed many times..

:
Deploying web application directory /var/www/web/www.mysite.com
:
:
Deploying web application directory /var/www/web/www.mysite.com
:
:

the file server.xml looks like :

.............
<Host name="www.mysite.com" appBase="/var/www/web" unpackWARs="true" autoDeploy="false">
    <Context path="" docBase="www.mysite.com" debug="0" reloadable="true"/>
</Host>
<Host name="www.mysitetwo.com" appBase="/var/www/web" unpackWARs="true" autoDeploy="false">
    <Context path="" docBase="www.mysitetwo.com" debug="0" reloadable="true"/>
</Host>
<Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">  
..........

How can avoid that?

Kuf
  • 17,318
  • 6
  • 67
  • 91
afterbit
  • 383
  • 7
  • 20
  • It's probably logging that for every http child that starts up. – Marc B Aug 27 '12 at 16:23
  • could you be more clear please? – afterbit Aug 27 '12 at 16:25
  • http://stackoverflow.com/questions/10292844/many-identical-apache-tomcat-children-being-spawned-automatically-at-startup-tim – Marc B Aug 27 '12 at 16:28
  • ok clear but i get this error on startup : org.apache.catalina.core.StandardContext loadOnStartup SEVERE: Servlet /www.mysite.com threw load() exception javax.management.InstanceAlreadyExistsException: ... and i think that this error is caused by the multiple deployments.. – afterbit Aug 27 '12 at 16:56

1 Answers1

3

I had a similar problem. I have 4 hosts, one context per host, and each Context has deployed 4 times.

The host deploys the explicit contexts defined in server.xml and the contexts in Application Base Directory.

The Application Base Directory is defined in <Host appBase="dir"> tag. The default is:

$CATALINA_BASE/webapps

If two or more hosts are using the same Application Base Directory, each subdirectory in Application Base will be deployed many time as the number of hosts.

I solved the problem keeping the $CATALINA_BASE/webapps empty and put each context out of Application Base Directory.

http://tomcat.apache.org/tomcat-7.0-doc/config/host.html

Plinio FM
  • 131
  • 1
  • 5
  • 1
    I'm experiencing this problem. In my case, app's are loaded at least 7 times. Could you tell me how did you configured the *appBase* parameter in your server.xml file?? Did you use a different appBase directory for each host? or did you left that parameter in blank? (appBase="") – Sergio Jun 08 '18 at 21:48
  • 1
    This site discourage you from saying "thank you", however, you saved me a lot of time and i don't think I could figure out what you did on my own. So THANKS A LOT!!!! – Sergio Jun 09 '18 at 03:31
  • Thanks from me also. This has got to be a bug - still not fixed in 2021. – dashman Mar 20 '21 at 21:48