Tomcat starts twice

When Tomcat starts up, the log file shows the server status.  We can understand how Tomcat works.  Due to different configuration, Tomcat may starts twice and runs two instances.

Why is that?

Let’s take a look at server.xml

<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
  <Context docBase="webabc" path="" reloadable="true" source="org.eclipse.jst.jee.server:webabc"/></Host>

The parameter specifies the generic application base under webapps directory. All web applications under that directory will be started by Tomcat.

Further, the parameter specifies an instance for webabc again. It will be called and started again.

That is why Tomcat has two instances.

To solve it, change the “appBase” in <Host> and “docBase” in <Context>.

<Host appBase="" autoDeploy="true" name="localhost" unpackWARs="true">
  <Context docBase="webapps/webabc" path="" reloadable="true" source="org.eclipse.jst.jee.server:webabc"/></Host>

Start Tomcat, it will only starts one instance.


Leave a Reply

Your email address will not be published.