Adverts
With the change in license of Java many applications that needed to be installed by hand have suddenly started being packaged by Debian. Tomcat was lucky in that it version 5.0 had been packaged but 5.5 wasn't hence the release of this other article describing installing installing tomcat and apache. I decided that as the tomcat5.5 package had been around a while I would give installing it a try.
First off install Java 6. There is very little point in being behind the curve here even if you aren't going to be using the features. Java is very extensivly tested for backward compatability and it is unlikely in the extreme that you will suffer any problems if you upgrade. The next step is important, use update alternatives for java and javac so that you are using the best version of Java on your machine. By default Debian installs the open source implimentations of Java which are fine projects but well behind in terms of features and speed. This can be done like this:
update-alternatives --config java update-alternatives --config javac
Now install tomcat5.5 and tomcat5.5-admin. The second package is optional but the management interface is very useful. This will install tomcat which, as it follows the standard Debian way of placing certain types of files in certain places installs conf, logs, shared, temp, webapps and work into /var/lib/tomcat5.5 and installs bin, common, doc and server into /usr/share/tomcat5.5.
Place any database drivers your application needs into /usr/share/tomcat5.5/common/lib. This is necessary only if you are using container managed data sources (which if you aren't you probably should be). You will probably need to modify your applictions context so that org.apache.commons.dbcp.BasicDataSourceFactory (packaged in commons-dbcp.jar) is sed rather than org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory (packaged in naming-factory-dbcp.jar). The latter comes with Tomcats downloaded from apache. Sadly the Debian Tomcat can't be used with Eclipse as Eclipe doesn't recognize the files at /var/lib/tomcat5.5 as a valid tomcat install.
It is now necessary to modify /etc/defaults/tomcat5.5. I change JAVA_OPTS to increase memory and remove -server option as it is not supported by Java 6 on 64 bit. I also comment in all the other options and set JAVA_HOME to something sensible like /usr/lib/jvm/java-6-sun. Finally I turn off the security manager as container security is enough if I am the only one deploying code to the contain.
If you want to use the administation applications modify /var/lib/tomcat5.5/conf/tomcat-users.xml. Add an admin user:
<role name="admin"/> <user name="admin" password="secret" roles="admin"/>
and a manager:
<role name="manager"/> <user name="manager" password="secret" roles="manager"/>
so that the management utility can be used.
To deploy an application place a war file in /var/lib/tomcat5.5/webapps and start Tomcat. There is currently a bug with the way Debian handles the logging for Tomcat which requires you to tail - f /var/log/tomcat5.5/catalina.out to get Tomcat to start.
If you choose to use the security manager you will probably get security exceptions if the application hasn't run with a security manager in place before (which is common if using tomcat through an IDE). The security policy files can be found in etc/tomcat5.5/policy.d.
To make Tomcat start at boot time:
update-rc.d tomcat defaults