Search This Blog

Monday, April 20, 2009

Installing Tomcat5.5 On Ubuntu 8.10 (Intrepid Ibex)

So whats next in my intrepid (he he he ... get it ..intrepid...Intrepid Ibex, ubuntu 8.10....ahhh never mind :-) ) adventures in trying to get a *nix development environment going. Well. I got Java happening in my last post. A web server would be good now. So tomcat here we come.

I want to install Tomcat 5.5 as our SOE at work is still Java 5 and Tomcat 5.5 so I went to the following URL at the tomcat website and downloaded three packages as tar.gz files:

which where called:

mkopka@random:~$ ls -l martys_stuff/
total 9892
-rw-r--r-- 1 mkopka mkopka 2401560 2009-04-20 15:33 apache-tomcat-5.5.27-admin.tar.gz
-rw-r--r-- 1 mkopka mkopka 855053 2009-04-20 15:32 apache-tomcat-5.5.27-deployer.tar.gz
-rw-r--r-- 1 mkopka mkopka 6478912 2009-04-20 15:32 apache-tomcat-5.5.27.tar.gz

Next i setup some directories where I wanted my setup to go. Im used to the following so this is what I used but your not limited to this:


Then i unzip and extracted the contents of each of the tar.gz files into the aforementioned directory. Now I thought, hooray Im done. I went to the bin directory and tried to run:

./ -version

...and rather than a happy version number proving all is good, I was rewarded with the following:

mkopka@random:~/tools/apache/tomcat-5.5.27/bin$ ./ version
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program

Well, heres me thinking Java was all happy after my last post, but obviously somethings not quite right so I did the following:

mkopka@random:~/tools/apache/tomcat-5.5.27/bin$ echo $JAVA_HOME

mkopka@random:~/tools/apache/tomcat-5.5.27/bin$ java -version
java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b02)
Java HotSpot(TM) Server VM (build 1.5.0_16-b02, mixed mode)
mkopka@random:~/tools/apache/tomcat-5.5.27/bin$ which java
mkopka@random:~/tools/apache/tomcat-5.5.27/bin$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2009-04-02 13:42 /usr/bin/java -> /etc/alternatives/java
mkopka@random:~/tools/apache/tomcat-5.5.27/bin$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2009-04-02 13:42 /usr/bin/java -> /etc/alternatives/java
mkopka@random:~/tools/apache/tomcat-5.5.27/bin$ ls -la /etc/alternatives/java
lrwxrwxrwx 1 root root 40 2009-04-14 18:23 /etc/alternatives/java -> /usr/lib/jvm/java-1.5.0-sun/jre/bin/java
mkopka@random:~/tools/apache/tomcat-5.5.27/bin$ ls -la /usr/lib/jvm/java-1.5.0-sun/jre/bin/java
-rwxr-xr-x 1 root root 65116 2008-05-28 18:30 /usr/lib/jvm/java-1.5.0-sun/jre/bin/java

So as you can see above, yep, no JAVA_HOME setup. And by doing some ls,-eing I was able to find where my java was installed. So time to set a JAVA_HOME and JRE_HOME:

/usr/lib/jvm/java-1.5.0-sun/ <--- thats the location of my Java 5

export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun/
export JRE_HOME=

I added these to my ~/.bashrc so that I would have these everytime i started a shell. Now running the same ./ version command i get:

mkopka@random:~/tools/apache/tomcat-5.5.27/bin$ ./ version
Using CATALINA_BASE: /home/mkopka/tools/apache/tomcat-5.5.27
Using CATALINA_HOME: /home/mkopka/tools/apache/tomcat-5.5.27
Using CATALINA_TMPDIR: /home/mkopka/tools/apache/tomcat-5.5.27/temp
Using JRE_HOME: /usr/lib/jvm/java-1.5.0-sun/jre
Server version: Apache Tomcat/5.5.27
Server built: Aug 28 2008 10:08:26
Server number:
OS Name: Linux
OS Version: 2.6.27-11-generic
Architecture: i386
JVM Version: 1.5.0_16-b02
JVM Vendor: Sun Microsystems Inc.

Woohoo!!!! It works I have the version number which is always a good start. So next, its time to cross fingers and try to start up the sever.

./ run

and I was happy to see a line saying:

INFO: Server startup in 1651ms

...and most importantly going to : http://localhost:8080/ shows me the tomcat startup page! We have lift off!!!

Okay, okay, okay, lets not get too excited yet. time to kill the server and setup some security stuff.

Setup Security
In order to use the tomcat manager and admin components you need to setup a username and password. There is a tomcat-users.xml file that can be used for this purpose:


is where the file is located in my install. Within it you'll find a number of users. You need to create a new admin user entry:

<user username="admin" password="admin" roles="admin,manager">

this is the user name and password to use for the admin and manager console and along with this you need the roles created as well so that the tomcat-users.xml file now looks like:

<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="admin"/>
<role rolename="manager"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
<user username="admin" password="admin" roles="admin,manager"/>

Library Driver Setup
Tomcat needs to have the DB drivers added to it for Oracle and PostgreSQL. If you don't add them you will get the error messages as shown here:

Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'
Put the Oracle JDBC jar into Tomcats lib directory: $CATALINA_HOME/lib (not into the applications libs directory!).
Note: if you use Tomcat 5.5.x: use $CATALINA_HOME/common/lib (and not $CATALINA_HOME/server/lib)!

Cannot load JDBC driver class 'org.postgis.DriverWrapper'
The full message is:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.postgis.DriverWrapper'

Same as above, requires the Postgis class added to the tomcat libs directory.

So you need to add the driver libraries. The libraries are added to:

$CATALINA_HOME/common/endorsed (or common/lib directory - not sure which one, try one then other if fails still)

and the libraries that need to be added are:


Testing of Port Setup
At this stage you should have a Tomcat install of the web server, the admin and the manager consoles. First check:


and confirm that the port number you are using is 8080. This is done by checking that the following block is available within the server.xml:

<service name="Catalina">
<connector port="8080" redirectport="8443" minsparethreads="25" connectiontimeout="20000" maxsparethreads="75" maxthreads="150">
<connector port="8009" redirectport="8443" protocol="AJP/1.3">
<engine defaulthost="localhost" name="Catalina">
<realm classname="org.apache.catalina.realm.UserDatabaseRealm">
<host appbase="webapps" name="localhost"></host>

Startup Of Server
Then you should be able to start the server by going to the bin/ directory and running

./ run | tee ../logs/standard_out.log

which runs Tomcat in the same window and also feeds the logs to the log file listed.

Testing of Server
You should now be able to go to :


which should bring up the tomcat start page. On the left side should be the options to go to the Tomcat manager and Administration. Test that you can go to both of these. The user name and password that were used in tomcat-users.xml is what is required to log in to both.

Deployment of Web Applications
Using the Tomcat Manager you can deploy a war file by selecting it with the browse button and then deploying it through the Tomcat Manager Deploy Tool. This should cause it to eventually appear in the Tomcat Manager list of applications. Then you should be able to either click on the application or type in:


(ie: /directory, /opengis-xls, etc etc, depending on the web app you deployed.)

No comments:

Post a Comment