How to Tomcat 5? Part 1
Posted by Alexandre Patchine on: 2006-05-30 21:54:48
Self SEO > Software Articles
I had no problem with Tomcat installation and all installation packages which
I tried, worked fine for me. I will not describe all installation steps, you always can find the
details on it on the home site for Apache Tomcat.
It was a few years ago, when Tomcat had version 4.1.0. My first impression was that I am swimming in a swamp, so slow
Tomcat was. The whole memory on my computer was consumed by Tomcat, every click on
my program interface resulted in freezing the whole machine for second. The
prstat (program in Solaris to supervise processes status, in Linux it is top
command) indicated that CPU jumped to 100%.
After 5 years with Apache server I was completely disappointed...
I thought that those guys, that always complain about Java, are right: it is just
waste of money, resources and time. This hungry (in terms of resources)
monster – Tomcat - will never fly!
I was not right. The problem was with settings, which were in my Tomcat
installation. Having used that Apache runs perfectly right away after an
installation, I was not ready for performance tuning. Honestly saying I
have no clue how to do that. Especially after working with
httpd.conf (Apache
configuration file) it was not so easy to get into multiple xml files, where
Tomcat’s configuration is spread around. Some strange things happened here and
there…
First step was to make everything working.
And soon Tomcat began to work better and better.
First problem was because of additional libraries in my web
applications. I could not link them from Tomcat’s
common/lib directory. I
had to have them just in one place, directly in the
common/lib, no linking for
another place!
Second problem was that, even if Tomcat's documentation claims that "*.war files
will be discovered in webapps directory and extracted automatically", they
actually sometime could be there for hours and nothing happened. Sometimes it
worked, sometime did not.
So, my advice to you: if you make an installation package for distribution
to many people, it will be safer to extract files from war files by your
installation program and do not rely on Tomcat. And you can disable this
feature at all (I do not rely on it).
How to move Tomcat from one directory to another?
My answer here is for the Solaris and Linux OSs. But it is very similar procedures for
Windows.
Tomcat 5.x, comparing to earlier versions, has quite good structure and properly
written configuration files. There are no files with hard coded paths or
versions. Everything is read from surrounding environment and it makes Tomcat
very transportable. You can easily move Tomcat from one place to another. Just
update environment variable
$CATALINA_HOME (this variable point to "home place"
of Tomcat).
For example, on my machine default place was:
/usr/local/tomcat.
Later I moved it to
/home/httpd/alex.
I was running Tomcat as tomcatuser and default shell for that user was
bash.
To find out which shell is default in your case you need to open the file
/etc/passwd and locate the line with tomcat’s user name. In my case this line
looked like this:
tomcatuser
:112:214:Tomcat process user/usr/local/tomcat /:/bin/bash
So, I opened the file
.bashrc in home directory for tomcatuser and changed two
lines:
CATALINA_HOME=/usr/local/tomcat
export CATALINA_HOME
to
CATALINA_HOME=/ home/httpd/alex
export CATALINA_HOME
That’s all. Now Tomcat 5 can run from new place.
It is just a beginning of my story about Tomcat. I continue my article about Tomcat tuning
(mostly performance) in the second part.
Alexandre Patchine publishes Java Programming Tips on the JavaFAQ.nu site and offers free "1000 Java Tips" e-book on his site. You can find many free Java books, Java Code examples and Java tools on his site. If you learn the Java the JavaFAQ.nu site is the best place to start and continue with your study!
Print this article
Tell a friend
 | Related Articles |
 | User comments: |
 | Post New Comment |
This site does not allow anonymous comments. Registered members can
login to participate.
Registration is free and takes only a few seconds