This post is targeted for the Middleware admins, Tomcat Administrators, JEE developers and QA analysts. here I am discussing my experiments and understanding about Apache Tomcat Servlet Engine.
Tomcat software is freely available as zip distribution and it is in binary and source codes on Apache Tomcat site. Before you install Tomcat you must install JDK and configure it in the environment variables in profile or in Windows system variables.
Sun JDK 1.5 for Tomcat 5
Sun JDK1.6 for Tomcat 6
Sun JDK 1.6 or 7 for Tomcat 7
In this post we are going to discuss about variety of operating systems such as Microsoft Windows 7, Oracle Solaris, Oracle/Redhat Linux.
You can have your own choice of selecting the versions but latest version will have more flexibility and bug fixes included.
For Windows 7 select 32bit or 64bit dependent zip files.
When you download Tomcat 7.0.30 the file apache-tomcat-7.0.30-windows-x86.zip will be downloaded. Extract this to your root directory C:\ or D:\. For our flexibility, rename the folder name with move command.
c:\>move apache-tomcat-7.0.30 Tomcat7
1 dir(s) moved.
Setup the JAVA_HOME, CATALINA_HOME in the System properties of your Windows Control Panel as show in the following picture.
1. Before installing tomcat make sure you set environment variable JAVA_HOME, JAVA_OPTS and CATALINA_HOME in .profile or If your default logon SHELL not bash then you run it thru command line then you must edit in the .bashrc or .bash_profile must have the two variables.
2. Download the latest tomcat installation file( apache-tomcat-5.5.17.tar.gz) and the Tomcat admin file(
3. Upload the installation file on the Solaris host, extract it contents using the following gunzip apache-tomcat-5.5.17.tar.gz into a folder /app/middleware/apache-tomcat-5.5.17., This will generate a tar file, use tar -xvf apache-tomcat-5.5.17.tar to extract the tar file to complete the installation process.
4. Similarly install the Tomcat Admin package.
5. Access the administration console the context path should be /admin
6. Starting the Tomcat server using startup.sh that is found in installation directory $CATALINA_HOME/bin.
7. Test the installation with http://localhost:8080 url, enter username admin password tomcat as default credentials. On successful installation following message will be displayed on the home page “If you're seeing this page via a web browser, it means you've setup Tomcat successfully. Congratulations!”
1. If you are facing the an issue with admin user credentials, replace the content of CATALINA_HOME/conf/tomcat-users.xml with the below code.
2. If you are see the following error while accessing the Tomcat server administration link “Tomcat's administration web application is no longer installed by default. Download and install the "admin" package to use it.” install the Tomcat admin package apache-tomcat-5.5.17-admin.tar if it is older version than 5 Here is the video tutorial by Gattu.
bin: Contains all the server life-cycle scripts(start, shutdown etc.,) for both Windows and Linux.
Using CATALINA_BASE: /app/middleware/apache-tomcat-5.5.17
Using CATALINA_HOME: /app/middleware/apache-tomcat-5.5.17
Using CATALINA_TMPDIR: /app/middleware/apache-tomcat-5.5.17/temp
Using JRE_HOME: /usr/jdk/instances/jdk1.5.0
Server version: Apache Tomcat/5.5.17
Server built: Apr 14 2006 02:08:29
Server number: 184.108.40.206
OS Name: SunOS
OS Version: 5.10
JVM Version: 1.5.0_28-b04
JVM Vendor: Sun Microsystems Inc.
Goto the Tomcat installation path and bin, there you can see “shutdown.sh” script file, this will terminate the Tomcat server.
You can confirm this by check the java process. Identify the process id with the following command
ps -fu <user> |grep java
The command pargs will gives you the all the arguments that passed for a command or shell script
Access the Tomcat Server through the Web browser give the admin credentials
The deployment option is in different form. You have two options for deployment. 1. Exploded directory form, you need to provide Context Path (optional), XML Configuration file URL, Directory URL
1. In the http://localhost:8080/manager/ Scroll down the page to the section called "Deploy directory or WAR file located on server". Enter the context name preceded by "/" (e.g., /Calendar) in the "Context Path" field.
2. Leave the "XML Configuration file URL" filed blank.
3. Locate Calendar WAR file and enter its absolute name (e.g., /absolute/path/Calendar.war) in the "WAR or Directory URL" field.
2. Web Archive (war)
1. Select Status from the left navigation bar of Tomcat home page
Display Name -- Name of your application
Running -- Lets you know the application status whether running or not
Sessions Current sessions count of the application
You have options to execute the following commands
Start to start the application when the application is stopped.
Stop Stop the application, when you access the application context path you will get the following message “HTTP Status 503 - This application is not currently available”
Reload Reloads the application with changes that you have made
Undeploy After the app has been stopped you can undeploy the app using 'undeploy'
Tomcat Book for free download only for Middleware Admin subscribers
In production environments we may need to setup this strategy to implement multiple Apache Tomcat instances. Details of how to do it is very clearly illustrated by Linux- Solutions blog: http://online-linux.blogspot.in/2011/02/how-to-configure-tomcat-in-linux.html