Thursday, August 13, 2009

Installing Tomcat - FAIL!

Previous: Installing support for Java development

Installing Tomcat should be routine. I've done it many times on Windows and OS X systems. Installing it on Ubuntu turned out to be a lengthy and frustrating experience.

The Ubuntu help pages have a description of how to install Tomcat system-wide or on a per-user basis for a development environment; see https://help.ubuntu.com/8.10/serverguide/C/tomcat.html.

I followed the instructions provided on that page under Using private instances. The commands to install Tomcat and to create a user-specific instance were:
sudo apt-get install tomcat6-user
tomcat6-instance-create my-instance
This resulted in a Tomcat installation under ~/my-instance. I'm not crazy about that directory name. Before changing it, I wanted to verify the installation was okay so far. I checked my-instance/conf/server.xml and saw it was set to listen on port 8080, so I left it alone. I ran this command:
my-instance/bin/startup.sh
Browsing to localhost:8080 in Firefox got me a blank document. I tried localhost:8080/manager and got a blank document. I tried localhost:8080/tomcat and got a blank document. In my-instance/logs, both catalina.out and the log file indicated startup was normal, services started properly, and showed no other activity and no errors. I had not seen this behavior in a Tomcat installation before.

I edited my-instance/conf/server.xml and changed the connector port to 8088, then tried it again. Same behavior. The documentation states that no webapps are deployed by default. That might be the reason it serves nothing but blank documents. Apparently, the manager app is not included in the per-user package. Normally, I expect to see the "It works!" message by default.

My next thought was to download the manager application by itself and drop it into the webapps directory. All the documentation I could find stated that the manager application is included by default in Tomcat installations. Clearly, this is not the case for the user-specific Ubuntu package.

The Ubuntu Tomcat help page listed this command to install the manager application, assuming you had installed the service version of Tomcat. It looked as if this might do the trick:
sudo apt-get install tomcat6-admin
Unfortunately, this resulted in a Tomcat service automatically installing and starting.

It was unclear how to shut the thing down manually. I found a posting online that indicated the start and stop commands are in /etc/init.d. I ran
/etc/init.d/tomcat6 stop
to shut down the instance. I was unable to locate a .war file for the manager app anywhere.

A task that should have taken me five minutes had now extended into hours. I had to stop and go to work. Before I gave up for the morning, I found a backup copy of another Tomcat installation on an external hard drive. I was thinking of copying the manager and host-manager applications from there to the user-specific Tomcat installation on Ubuntu, but on reflection I realized this was not a repeatable or reliable way to install software.

I decided to install dev instances of Tomcat the "old-fashioned way."

Next: Installing Tomcat

1 comment:

  1. I had the same brain fart as you mentioned before. I found a proper method. So I did the following:

    1:
    sudo aptitude install tomcat6-user tomcat6-admin

    2: useradd -m -g users -s /bin/bash testuser

    3: passwd testuser

    4: su - testuser

    5: tomcat-instance-create testinstance

    6: vi /home/testuser/testinstance/conf/server.xml

    changed the port to 8006 and 8081 from the default 8005 and 8080

    7: cd /home/testuser/testinstance/webapps

    8: ln -s /usr/share/tomcat6-admin/manager
    9: ln -s /usr/share/tomcat6-admin/host-manager
    10: vi /home/testuser/testinstance/conf/tomcat-users.xml

    added in the following:







    11: /home/testuser/testinstance/bin/startup.sh

    I was then able to goto http://:8081/manager/html

    and have the manager for that instance.

    ReplyDelete