Apache Tomcat

This article is about installing Apache Tomcat version 6.0.35-r1 and newer and 7.0.29-r1 and newer. Official Gentoo Project documentation for Tomcat can be found in the resource links to the right. There are significant changes in how Tomcat is configured so be sure to use the correct guide for the job.

Installation
To install Tomcat, emerge. By default, only manager and host-manager applications are installed. To install Tomcat documentation and example applications, enable the  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 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 text:

Follow the information in the help to create new Tomcat instances. Tomcat instances use the following layout:


 * : 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

Start a Tomcat instance using following command:

To start a Tomcat instance on boot, run following command:

Migrating old Tomcat instances
To migrate Tomcat instance from Tomcat installation that supported only single instance, follow these steps:


 * Stop old version of Tomcat
 * Upgrade Tomcat to new version
 * Create new Tomcat instance, for example:


 * Configure Tomcat files of the new instance ( and ) and copy your applications from the old instance to the new one
 * Make new Tomcat instance to start after boot if required:


 * Start the new instance:

Integrating Tomcat with Netbeans
Integration of Tomcat with Netbeans is easy. Run the instance manager with  command line option and specify user name of the user being creating for the Catalina base. 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 configure Tomcat in Netbeans Servers configuration dialogue. 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 appropriate suffix used when creating the instance.

Need dependent jars in classpath
java-config in the init script should include  so that dependent JARs get added automagically to the classpath. See for more information.

Tomcat fails to start after update
You may need to update your init script and catalina properties:

See.