Blog Archive

Install Tomcat on iSeries - As400 Tomcat 6.0 installation steps

How to Setup Tomcat as Stand-Alone Server on iSeries

Here we are going to download a fresh copy of the Tomcat from the Apache website and run it as a Stand Alone Server. Basically hitting the Tomcat directly without going thru Apache Web Server. In the next part I am going to connect it to the Apache Web Server.

Useful Links:

Follow the Steps:

1) Go to the Apache Tomcat Home page and down the zip file for the version you want to install. Before choosing a version make sure you have compatible Java version already installed on the iSeries. I am going to install the Tomcat 6.0
Servlet/JSP Spec Apache Tomcat version Actual release revision Minimum Java Version
3.0/2.2    7.0.x     7.0.14     1.6
2.5/2.1    6.0.x     6.0.32     1.5
2.4/2.0    5.5.x     5.5.33     1.4
2.3/1.2    4.1.x (archived)  4.1.40 (archived)  1.3
2.2/1.1    3.3.x (archived)  3.3.2 (archived)  1.1

I went and downloaded apache-tomcat-6.0.32.zip

2) Create a IFS directory called apache where we are going to install the zip file.
MD DIR('/apache')

3) Now FTP the apache-tomcat-6.0.32.zip to the /apache directory. You can download Filezilla for this, its free - FileZilla Home Page

OR

Use the DOS command prompt FTP
ftp {system_name or IP Address}
Enter UserId
Enter Password
bin

quote site na 1
put apache-tomcat-6.0.32.zip /apache/apache-tomcat-6.0.32.zip
quit

4) Unzip the file in the /apache directory
Once you have the Zip file on your iSeries, start a Qshell session, using the command QSH. Change to /apache directory and extract the Zip file, using the following commands:
cd /apache
jar -xf apache-tomcat-6.0.32.zip

5)After the file unzips you will see the sub directory apache-tomcat-6.0.32 created under /apache directory. Your can drill down and see Tomcat directory structure

Install Tomcat 6.0 on iSeries As400

6)Now that you have Tomcat on your system, you should compile and optimize all of the JAR files packaged with Tomcat. This takes a while ..(This step is optional)
SBMJOB CMD(QSH CMD('for jar in $(find /apache/apache-tomcat-6.0.32/ -name ''*.jar''); 
do system "CRTJVAPGM CLSF(''"$jar"'') OPTIMIZE(40)";done')) 
JOB(COMPILE_) JOBQ($jobqName)

7)Modify catalina.sh file. Its available under bin directory. In my case here is the path

/apache/apache-tomcat-6.0.32/bin/catalina.sh
Look for os400=false and update it to os400=true

8) CL program to start the Tomcat 6.0 Server
PGM                                                       
                                                          
ADDENVVAR  ENVVAR(JAVA_HOME) +                            
             VALUE('/QIBM/ProdData/Java400/jdk15')        
MONMSG     MSGID(CPF0000)                                 
                                                          
SBMJOB     CMD(QSH +                                      
             CMD('/apache/apache-tomcat-6.0.32/bin/start+ 
             up.sh')) JOB(CATALINA) JOBQ($jobqName) +        
             CPYENVVAR(*YES) ALWMLTTHD(*YES)              
                                                    
ENDPGM        

9) If your Tomcat Server doesn't start check the log file. Log file resides in 

CATALINA_HOME/logs/catalina.out

In my case the path is /apache/apache-tomcat-6.0.32/bin/catalina.sh
CATALINA_HOME = /apache/apache-tomcat-6.0.32

If you see the following error
Caused by: java.lang.UnsatisfiedLinkError: no cmm in java.library.path

then you have to update you Java system properties file
/QIBM/UserData/Java400/systemdefault.properties

Add the following lines
java.awt.headless=true                                  
java.library.path=/QIBM/ProdData/Java400/jdk15/lib/cmm  


10) Make sure your Tomcat Sever in running, Sample log info for successful start
May 27, 2011 4:19:14 PM org.apache.coyote.http11.Http11Protocol init                    
INFO: Initializing Coyote HTTP/1.1 on http-8080                                         
May 27, 2011 4:19:14 PM org.apache.catalina.startup.Catalina load                       
INFO: Initialization processed in 9827 ms                                               
May 27, 2011 4:19:15 PM org.apache.catalina.core.StandardService start                  
INFO: Starting service Catalina                                                         
May 27, 2011 4:19:15 PM org.apache.catalina.core.StandardEngine start                   
INFO: Starting Servlet Engine: Apache Tomcat/6.0.32                                     
May 27, 2011 4:19:15 PM org.apache.catalina.startup.HostConfig deployDescriptor         
INFO: Deploying configuration descriptor host-manager.xml                               
May 27, 2011 4:19:19 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor manager.xml                           
May 27, 2011 4:19:22 PM org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory ROOT                                 
May 27, 2011 4:19:22 PM org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory docs                                 
May 27, 2011 4:19:23 PM org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory examples                             
May 27, 2011 4:19:26 PM org.apache.coyote.http11.Http11Protocol start          
INFO: Starting Coyote HTTP/1.1 on http-8080                                    
May 27, 2011 4:19:26 PM org.apache.jk.common.ChannelSocket init                
INFO: JK: ajp13 listening on /0.0.0.0:8009                                     
May 27, 2011 4:19:26 PM org.apache.jk.server.JkMain start                      
INFO: Jk running ID=0 time=0/378  config=null                                  
May 27, 2011 4:19:27 PM org.apache.catalina.startup.Catalina start             
INFO: Server startup in 12785 ms    

11) Check the Tomcat Home Page, Type the following on your web browser

http://www.yourserver.com:8080/
OR
http://iSeries_Ip_Address:8080/
               
Sample Apache Tomcat 6.0 Home Page

12) To use the Tomcat Manager you need a user profile setup for manager role. Go to

CATALINA_HOME/conf/tomcat-users.xml

Add the following lines after <tomcat-users>
<role rolename="manager"/>                                 
<role rolename="admin"/>                                   
<user username="{your user id}" password="{your password}" roles="admin,manager"/>

13) For these changes in user config to take place you have to restart the Tomcat Server. So lets Stop the server. Here is a sample CL program to stop the Tomcat 6.0 Server
PGM                                                      
                                                         
ADDENVVAR  ENVVAR(JAVA_HOME) +                           
             VALUE('/QIBM/ProdData/Java400/jdk15')       
MONMSG     MSGID(CPF0000)                                
                                                         
SBMJOB     CMD(QSH +                                     
             CMD('/apache/apache-tomcat-6.0.32/bin/shut+ 
             down.sh')) JOB(CAT_END) JOBQ($jobqName) +      
             CPYENVVAR(*YES) ALWMLTTHD(*YES)             
                                                         
ENDPGM     

13) Start the Tomcat Server again and you are all set !

Recommended Reading