iCluster and Mobility Part 3: Apache Tomcat for Dummies

The iCluster Mobile Monitor as provided in iCluster 7.1 TR23 is basically a collection of JAVA classes and JAVA servlets that connect to the IBM i server running iCluster. JAVA servlets are JAVA programs that extend the capabilities of a server. Although servlets can respond to any types of requests, they most commonly implement applications hosted on Web servers. So since they need to be “served up” you need to install a special program called a servlet engine to turn your computer into a server that’s capable of running servlets.

The best-known servlet engine is Apache Tomcat, which is available free from the Apache Software Foundation. It is very popular, and is the backbone behind many high traffic websites like:

  • LinkedIn.com
  • Dailymail.co.uk
  • Comcast.net
  • Wallmart.com
  • Reuters.com

Some key points about Apache Tomcat include:

  • Apache Tomcat was previously called as Jakarta Tomcat
  • Apache Tomcat is composed of components like Catalina, Jasper JSP and Coyote
  • Apache Tomcat server is available in both Binary and open-source versions
  • Apache Tomcat server requires Java Runtime environment (JRE) as a prerequisite
  • Apache Tomcat server can be used as a standalone product or can be integrated with other web servers like Microsoft IIS, Netscape Server and Apache HTTP server

It is very easy to get Tomcat installed on wither your Windows laptop/PC or Server or even your IBM I server. Let’s get started! I will assume since “IBM i rules!” we will want to install Apache Tomcat on your Power System or PureFlex System running IBM i.

  1. Download the distribution zip file from here: http://apache.mirror.iweb.ca/tomcat/tomcat-7/v7.0.63/bin/apache-tomcat-7.0.63.zip
  2. Upload Tomcat V7.0.28 distribution to IBM i and place it in an integrated file system directory, for example, /home/download.

Tech Tuesday July 14 -1

3. Extract the Tomcat distribution file in Qshell:

  • cd /home/download
  • jar -xvf apache-tomcat-7.0.28.zip

4. Set the JAVA_HOME environment variable. In order for Tomcat to start and run, it needs to know where the Java virtual machine (JVM) is located. This information needs to be added to the Tomcat configuration file. Edit the Tomcat configuration file: /home/download/apache-tomcat-7.0.28/bin/setclasspath.sh.

  • WRKLNK ‘/home/download/apache-tomcat-7.0.28/bin’
  • Option 2 to edit next to setclasspath.sh
  • Insert a new line using I for insert and type:
  • export -s JAVA_HOME=/QOpenSys/QIBM/ProdData/JavaVM/jdk60/32bit/

Tech Tuesday July 14 -2

5. Start Tomcat V7 on IBM i.

  • Verify the availability of the ports used by Tomcat. Tomcat uses 8005, 8080, and 8009 by default among which 8080 is the default HTTP port. Enter the command NETSTAT OPTION(*CNN) to verify whether the ports are in use.
  • If port 8009 and 8080 are occupied, edit the configuration file, /home/download/apache-tomcat-7.0.28/conf/server.xml, to change default ports 8005, 8009, and 8080 to other ports which are not in use. If you have multiple Tomcat servers running on this IBM i, you will need to use different ports for these values.

Tech Tuesday July 14 -3

  • Update the configuration of the Tomcat Web Application Manager. We need to update the configuration of the application to add a new role and user name before starting Tomcat. Edit /home/download/apache-tomcat-7.0.28/conf/tomcat-users.xml
    • WRKLNK ‘/home/download/apache-tomcat-7.0.28/conf
    • Option 2 for edit next to tomcat-users.xml
    • Add <role rolename= “manager-gui”/> after all existing role elements.
    • Add <user username=”admin” password=”admin” roles=”manager-gui”/> after all existing user elements.
    • Remove the <!… before the first role, and F3 twice to save and exit

Tech Tuesday July 14 -4

  • Start Tomcat. Tomcat is installed and configured successfully. It is now ready to start through a script in Qshell. Change to the Tomcat bin directory, in this example, /home/download/apache-tomcat-7.0.28/bin. There are several useful scripts such as startup.sh, shutdown.sh, setClasspath.sh, Catalina.sh, and so on in this directory.
  • You can run ./startup.sh to start the server but the server will only be active during the current interactive session. The preferred method is to submit it as a batch job using:
  • SBMJOB CMD(QSH CMD(‘/home/download/apache-tomcat-7.0.28/bin/startup.sh’)) JOB(STRTOMCAT7) JOBQ(QBATCH)
  • Or even better set it up as a job schedule entry using WRKJOBSCDE to add a new job schedule entry called STRTOMCAT7 with a command to run *ONCE and make sure it is saved.

Tech Tuesday July 14 -5

  • Verify that Tomcat is started on IBM i. Verify whether the Tomcat server is running by entering the CL command, WRKACTJOB. Look for the QP0ZSPWT job in the QINTER subsystem and make sure that its status is TIMW.

Tech Tuesday July 14 -6

  • Verify that Tomcat works correctly on IBM i.
    1. Open a web browser and enter the URL http://your.server.name:8080/manager.
    2. Enter the default user ID and password (admin/admin) when prompted. The manager application is displayed as shown in the following figure :

Tech Tuesday July 14 -7

At this point we have a running Apache Tomcat installation on IBM. Now we need to tell Apache about the Mobile Monitor. We will cover that in our next post – so stay tuned!

The following two tabs change content below.

iCluster Tech Tuesday

iCluster TechTuesday is a set of posts covering technical tips and techniques to help get the most out of your Rocket iCluster installation.

, ,

No comments yet.

Leave a Reply