View Source

h1. Requirements

You need Tomcat 5.0 or later.

h1. Installation

To install Hudson on Tomcat, simply copy {{hudson.war}} to {{$TOMCAT_HOME/webapps}}, then access {{[http://yourhost/hudson]}}.

If you are running Tomcat just to host Hudson, then remove everything from {{$TOMCAT_HOME/webapps}}, and place {{hudson.war}} as {{ROOT.war}}. Tomcat should expand this and create the {{ROOT}} directory, and you should see Hudson in {{[http://yourhost|http://yourhost/]}} (if you accepted the Tomcat defaults - {{[http://yourhost:8080|http://yourhost:8080/]}}) without any additional path. This also works nicely when you set up a virtual host, as it allows a single Tomcat instance to run multiple applications, yet users can still access your hudson with URLs like {{[http://hudson.acme.org/]}} without any additional path. See the Tomcat documentation for more about how to set up a virtual host.

h1. Upgrade

Simply overwrite your {{hudson.war}} with the new version and delete the hudson folder in webapps (exploded war). Tomcat should automatically redeploy the application.

h1. Setting HUDSON_HOME

Before starting Tomcat, set CATALINA_OPTS like this. This can be also used to specify JVM options to increase the heap size:
{noformat}$ export CATALINA_OPTS="-DHUDSON_HOME=/path/to/hudson_home/ -Xmx512m"
$ catalina.sh start
{noformat}Or on Tomcat 1.6+ CATALINA_OPTS has been replaced by JAVA_OPTS (Thanks to Ronoaldo Pereira):
{noformat}$ export JAVA_OPTS="-DHUDSON_HOME=/path/to/hudson_home/ -Xmx512m"
$ catalina.sh start
{noformat}Or if that fails for some reason, you should still be able to use the environment variable:
{noformat}$ export HUDSON_HOME=/path/to/hudson_home/
$ catalina.sh start
{noformat}

h1. Increasing Tomcat PermGen space

If you see permgen errors when running Tomcat, edit the catalina.sh file on \*NIX systems to assign the following options
{noformat}
JAVA_OPTS="-Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m"
{noformat}
Or on windows use the Configure Tomcat GUI Java panel to set the same additional options and restart Tomcat.

h1. Securing Hudson on Tomcat

Tomcat by default stores the user database in an XML file called {{$TOMCAT_HOME/conf/tomcat-users.xml}}. You can add the following lines to this file to create an admin user.
{noformat:xml}<role rolename="admin"/>
<user username="hudson-admin" password="secret" roles="admin"/>
{noformat}

h1. i18n

Some versions of Tomcat (such as 5.0.28) uses iso-8859-1 to decode URLs, which is in a clear violation of the relevant RFCs. To fix this problem, add the following {{URIEncoding}} attribute to the connector definition in {{$TOMCAT_HOME/conf/server.xml}}.
{noformat}<Connector port="8080" URIEncoding="UTF-8"/>
{noformat}Other people reported that [a presence of {{RequestDumperValve}} would also cause a problem|https://hudson.dev.java.net/issues/show_bug.cgi?id=302].

h4. Related reads

# [Similar instruction for Confluence|http://confluence.atlassian.com/display/DOC/Configuring+Tomcat's+URI+encoding]
# [John O'Conner's blog entry about his experiment|http://weblogs.java.net/blog/joconner/archive/2005/07/charset_traps.html]. See Elliotte(id:elharo)'s comment in particular,

h1. Relevant Issues

See the [list of issues|http://issues.hudson-ci.org/secure/IssueNavigator.jspa?mode=hide&requestId=10130] filed that are specifically marked relevant to Tomcat.

There is also a [known issue|http://issues.hudson-ci.org/browse/HUDSON-6473?focusedCommentId=138461&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_138461] in Tomcat 6.0.21 to 6.0.26 that may cause some requests to hang.

h3. Tomcat from XAMPP

If you are using XAMPP's tomcat installation, and you have Java > 1.5, then you need to remove the following jars from the common\lib directory, otherwise you will get FileNotFound exceptions from the changelog.xml generator:
{noformat}xalan.jar
xercesImpl.jar
xercesSamples.jar
{noformat}

h3. Tomcat from Ubuntu

If you get Tomcat from Ubuntu via apt-get, Hudson will report an error citing the security permission issue. This is because Tomcat in Ubuntu comes with the security manager on by default. This can be disabled by modifying {{/etc/default/tomcat5}} (version number will be different depending on which version of Tomcat you install.) See [719@issue] for more details.

h3. Tomcat from Debian

Fix security issues adding the next lines at {{/etc/tomcat5.5/policy.d/04webapps.policy}}:
{noformat}
grant codeBase "file:/var/lib/tomcat5.5/webapps/hudson/-" {
permission java.security.AllPermission;
};
{noformat}

h3. Tomcat from Windows


h4. GUI Testing in Windows

Most Windows services \-\- including those run with the option "Allow service to interact with desktop" in Windows XP and Vista \-\- do not have access to many of the computer's resources, including the console display.&nbsp; This may cause Automated GUI Tests to fail if you are running Apache Tomcat as a Windows Service and are doing any GUI testing. This is true at least for AWT and Abbot frameworks.&nbsp; A typical error might look similar to this:
{noformat}[junit] \# An unexpected error has been detected by HotSpot Virtual Machine:
[junit] \#
[junit] \# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d07baf4, pid=3260, tid=288
[junit] \#
[junit] \# Java VM: Java HotSpot(TM) Client VM (1.5.0_09-b03 mixed mode, sharing)
[junit] \# Problematic frame:
[junit] \# C [awt.dll+0xbaf4|awt.dll+0xbaf4]
[junit] \#
{noformat}This limitation can be resolved by not running Tomcat as a Windows Service, but instead through a "Scheduled Task" as an Application that runs at logon. There are several options for doing this, an example would be&nbsp; to run "$TOMCAT_HOME\bin\tomcat5.exe".&nbsp; When setting up the scheduled task in Windows Vista consider choosing the check-box for "Run with highest privileges" from the general tab, as this removes the need to always provide administrator privileges and may resolve other issues as well.

&nbsp;
\*Note: This workaround/fix may or may not require an admin to be logged in during testing.&nbsp; Running your tests while logged in as a standard user this is fine, but some modifications may need to be made for your individual configuration.