Sunday, April 11, 2010

Installing Tomcat (partial FAIL)

Previous: Installing Java support

The last time I installed Tomcat on Ubuntu 9.04, the documented easy installation method didn't work and I resorted to installing from a tarball. Since I'm installing 9.04 again rather than a later release, there's no reason to expect different behavior from the installer today.

This time, I want to run Tomcat from a hidden directory under /home so that the everyday view of /home won't be cluttered with various development tools, as before. I decided to go with Tomcat 5.5 for the moment.

I wanted to be able to run customized Tomcat instances for particular development projects on localhost. To that end, I configured a vanilla instance to use as a template to copy into different projects as needed.

This is what I did:

Install Tomcat Core



1. Went to http://tomcat.apache.org/ and download the following distros:

* Core
* Deployer (did not install this)
* Administration Web Application (did not install this)

2. Under /home/.bin I created a directory for local Tomcat instances, tomcat. So I had /home/.bin/tomcat.

3. Moved the Core tarball to /home/.bin/tomcat and unpacked it in place using

tar xzfv *

This resulted in a directory containing the Tomcat core at /home/.bin/tomcat/apache-tomcat-5.5.28.

4. Deleted the tarball apache-tomcat-5.5.28.tar.gz.

5. Granted execute permission on everything in Tomcat's bin directory

cd /home/.bin/tomcat/apache-tomcat-5.5.28/bin
chmod +x *


6. Edited [TOMCAT-HOME]/conf/tomcat-users.xml and changed the default entries

<tomcat-users>
<user name="tomcat" password="tomcat" roles="tomcat" />
<user name="role1" password="tomcat" roles="role1" />
<user name="both" password="tomcat" roles="tomcat,role1" />
</tomcat-users>

to

<tomcat-users>
<user name="tomcat" password="tomcat" roles="tomcat" />
<user name="admin" password="admin" roles="tomcat,manager" />
</tomcat-users>


7. Set the JAVA_HOME environment variable. To find out the value to set, I looked in /etc/alternatives for the java link and found /usr/lib/jvm/java-6-sun/jre/bin/java. So, the value for JAVA_HOME should be /usr/lib/jvm/java-6-sun/jre. Edited /etc/environment and added the line:

JAVA_HOME="/usr/lib/jvm/java-6-sun/jre"


8. Gave Tomcat a trial run:

cd [TOMCAT-HOME]/bin
startup.sh

Exceptions were thrown complaining that native libraries recommended for good performance in a production environment were not found. This is not relevant to my localhost dev environment.

Opened a browser and went to localhost:8080. Tomcat was up and running. The Manager application worked with the userid and password I had set in tomcat-users for the admin role.

Install Administration Web Application — FAIL



1. Unpacked the Administration Web Application tarball to a temporary location.

2. Copied directory server/webapps/admin to [TOMCAT-HOME]/server/webapps.

3. Copied conf/Catalina/localhost/admin.xml to [TOMCAT-HOME]/conf/Catalina/localhost.

4. Restarted Tomcat.

Tomcat restarted normally. Going to http://localhost:8080/admin just resulted in the default message that the Administration app is not shipped by default anymore. Going to Manager, I could see the admin application deployed but not active. Choosing start resulted in an unhelpful message telling me that the app could not be started.

I found a number of threads online where people had reported the same problem. There were several workarounds, and I tried a couple. Apparently this problem occurs sometimes, but not always, and people are able to work around it by uninstalling and reinstalling, possibly five or six times, but this does not always fix the problem. In my case, it made no difference.

My personal view is that tools should not get in our way. The truth is I don't need the Administration app for local development. I don't really need the Deployer, either, so I blew off even trying to install it.

Since I finally got a basic Tomcat instance up and running, I won't delete it. However, the next time I'm working on a Java-based webapp, I'm going to try some alternatives to Tomcat. I've heard good things about Jetty and Glassfish. There are others, as well. Tomcat used to be pretty handy, but now it's evolved to the point that there's more administrative overhead involved with it than the value it returns, for purposes of development. It's still a nice servlet container when used in conjunction with Apache HTTP Server in production, but I'm done using it as a development tool unless and until they make it work smoothly.

Next: Installing .NET development support

No comments:

Post a Comment