Apache Tomcat

This guide is about installing Apache Tomcat version 6.0.35-r1 and newer and 7.0.29-r1 and newer. You can find older Gentoo guides at Tomcat Guide and Tomcat 6 Guide. There is a significant change in how Tomcat is configured so make sure you use the correct guide according to the version you are installing.

Installation
To install Tomcat, emerge. By default, only manager and host-manager applications are installed. If you want to install Tomcat documentation and example applications, you have to enable USE flag. The ebuild installs only what is known as Catalina home. Creation of Catalina base is described in next section.

Configuration
Since version 6.0.35-r1 and 7-0-29-r1, Tomcat supports running of multiple instances. This largely affects the way how Tomcat is configured. The preferred way to create and configure Tomcat instances is by using Tomcat instance manager located at for Tomcat 7 and at  for Tomcat 6. Running the instance manager without any parameter displays following help:

Follow the information in the help to create new Tomcat instances. Tomcat instances use the following layout: You can run Tomcat instance using following command:
 * : configuration file for running Tomcat instance services
 * : controlling script for the Tomcat instance
 * : directory containing standard Tomcat configuration files
 * : Catalina base directory
 * : directory for instance log files

If you want to start Tomcat instance on boot, run following command:

Integrating Tomcat with Netbeans
Integration of Tomcat with Netbeans is easy. You run instance manager with command line switch and you specify user name of the user you are creating Catalina base for. The newly created Catalina base files are then owned by the specified user and are fully accessible by Netbeans when being run under that user. Now you can configure Tomcat in Netbeans Servers configuration dialog. When using Tomcat 7, use as Catalina home and  as Catalina base. When using Tomcat 6, use as Catalina home and  as Catalina base. In both cases replace suffix with the real suffix you used when creating the instance.