Apache Tomcat




Kill Tomcat port in use

http://stackoverflow.com/questions/8509125/apache-tomcat-8009-port-in-use


How do I update a Tomcat webapp without restarting the entire service

use Tomcat's Manager application? It allows you to undeploy / deploy war files with out shutting Tomcat down.

If you don't want to use the Manager application, you can also delete the war file from the webapps directory, Tomcat will undeploy the application after a short period of time. You can then copy a war file back into the directory, and Tomcat will deploy the war file.

If you are running Tomcat on Windows, you may need to configure your Context to not lock various files.

If you absolutely can't have any downtime, you may want to look at Tomcat 7's Parallel deployments You may deploy multiple versions of a web application with the same context path at the same time. The rules used to match requests to a context version are as follows:
  • If no session information is present in the request, use the latest version.
  • If session information is present in the request, check the session manager of each version for a matching session and if one is found, use that version.
  • If session information is present in the request but no matching session can be found, use the latest version.

There will be a small amount of time that the application is unavailable. It depends on your hardware / application how long that time is. But it's measured in seconds, I'd say usually 5-10 on our applications.


Tomcat multiple instances simultaneously


Here's how I usually do it for Windows (the important parts for setup are in steps 2, 3, 4 and 5):

Install a copy of Tomcat 6 to a directory (like C:\apache-tomcat-6.0.20).
Copy the conf directory to another directory (like C:\tomcat-1)
Under C:\tomcat-1, create a bin directory
In the C:\tomcat-1\bin directory, create a file called startup.bat that reads like this:

set CATALINA_BASE=C:\tomcat-1

set CATALINA_HOME=C:\apache-tomcat-6.0.20

C:\apache-tomcat-6.0.20\bin\startup.bat

In the C:\tomcat-1\bin directory, create a file called shutdown.bat that reads like this:

set CATALINA_BASE=C:\tomcat-1

set CATALINA_HOME=C:\apache-tomcat-6.0.20

C:\apache-tomcat-6.0.20\bin\shutdown.bat

OPTIONAL: create a file called setenv.bat in the C:\tomcat-1\bin directory to set any environment variables mentioned in C:\apache-tomcat-6.0.20\bin\catalina.bat. This is the place to set system properties, JPDA addresses, etc.

Create the logs, temp, webapps and work directories under C:\tomcat-1
From the C:\tomcat-1 directory, run bin\startup.bat
Repeat for your other installs from step 2 for as many tomcat instances as you need.
Try not to install Tomcat in a directory that has spaces in its name. It should work, but you'll experience fewer problems that way. I do not know how this would work if you were using the "tomcat as a service" option for Windows.

From here, you should be able to isolate tomcat instances. Just be sure to edit your conf\server.xml file so that the shutdown ports and HTTP connector ports don't interfere with other Tomcat instances that may be running. I usually assign values like 8005, 8006, 8007, etc. for the shutdown port and 8080, 8081, 8082, etc. for the HTTP connector port.




Comments