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


10 comments :

  1. We noticed some strangeness when applying this procedure to Tomcat 7:

    With Tomcat 6, when I start Tomcat, the "CATALINA" job
    brings up the server, then ends, leaving the server active.

    But with Tomcat 7, when I start it, the "CATALINA" job remains active,
    and if I abend it, it takes the server with it.

    Is this normal? Is there some setting that needs to change? Something in
    one of the scripts? Something in the CL program that initiates the whole
    process?

    I'm asking the same question a few other places.

    --
    James H. H. Lampert
    Touchtone Corporation

    ReplyDelete
  2. James,

    I haven't installed Tomcat 7 yet. When I do it next time I will try and let you know. If you get your question answered please share it, so it can help others.

    ReplyDelete
  3. A member of the Java list on Midrange.com has experienced the same thing as I described, and as far as he knows, it's "just the way it works."

    Given that, I simply adjusted the CL programs to use a *JOBD that is guaranteed never to clog a "one-at-a-time" *JOBQ.

    ReplyDelete
  4. And now, we tried to install it on a customer's V7 box, and hit a brick wall: CATALINA crashes on takeoff, because Java is not where it's expected to be.

    According to GO LICPGM, Java 6 is present.

    But according to WRKLNK, it's not where it is on a V6 box.

    Any ideas?

    --
    JHHL

    ReplyDelete
  5. James H. H. LampertJanuary 9, 2012 at 5:03 PM

    Do you know anything about getting SSL support up?

    I was referred to:
    http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html

    I've tried, both with an explicitly named and located keystore (and password), and with the defaults. So long as I'm not trying to access a nonexistent keystore, I get:

    java.io.IOException: Keystore was tampered with, or password was incorrect

    ReplyDelete
  6. I never done it but will give it a try in a few days and let you know. I have always put Apache in front of Tomcat for SSL.

    One thing is for sure from the error is that your server.xml config is good and its finding the keystore but the password doesn't match. I have worked with Android apps and they need to be created with keystore and if you forget the password then it will give the same message. Check your CCSID for server.xml file make sure you have 819.

    ReplyDelete
  7. James H. H. LampertJanuary 23, 2012 at 12:45 PM

    More weirdness, this time with a V5R4 box.

    They have Java 6 installed, and I'm told that they installed some PTFs over the weekend, but it's still crashing on takeoff.

    In catalina.sh, we have:
    > # Java 6 settings if needed
    > export -s JAVA_HOME=/QOpenSys/QIBM/ProdData/JavaVM/jdk60/32bit/jre
    > export -s CATALINA_HOME=/wintouch/tomcat
    > export -s JAVA_OPTS="-Dos400.awt.native=true -Djava.awt.headless=true -Djava.version=1.6 -Xms256m -Xmx512m"
    >
    > # OS specific support. $var _must_ be set to either true or false.
    > cygwin=false
    > darwin=false
    > os400=true
    > case "`uname`" in
    > CYGWIN*) cygwin=true;;
    > Darwin*) darwin=true;;
    > OS400*) os400=true;;
    > esac

    and there is definitely a "java" in the /QOpenSys/QIBM/ProdData/JavaVM/jdk60/32bit/jre/bin directory, and so far as I'm aware, all the JARs are present in the right subdirectories of /wintouch/tomcat, but in catalina.out, I get:
    > Attaching Java program to /QIBM/ProdData/Java400/jdk6/lib/charsets.jar.
    > Attaching Java program to /QIBM/ProdData/Java400/jdk6/lib/resources.jar.
    > Attaching Java program to /QIBM/ProdData/Java400/jdk6/lib/rt.jar.
    > eval: 001-0014 Command /QOpenSys/QIBM/ProdData/JavaVM/jdk60/32bit/jre/bin/java not found.
    > java.lang.ClassNotFoundException: org.apache.catalina.startup.Catalina
    > at java.net.URLClassLoader.findClass(URLClassLoader.java:432)
    > at java.lang.ClassLoader.loadClass(ClassLoader.java:642)
    > at java.lang.ClassLoader.loadClass(ClassLoader.java:608)
    > at org.apache.catalina.startup.Bootstrap.init(Bootstrap.java:236)
    > at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:425)

    When I delete catalina.out and try again, I get the same, only starting from the ClassNotFoundException.

    Any idea what the problem could be here?

    --
    JHHL

    ReplyDelete
  8. Do not modify catalina.sh. Create a CL program as explained above.

    PGM
    ADDENVVAR ENVVAR(JAVA_HOME) +
    VALUE('/QOpenSys/QIBM/ProdData/JavaVM/jdk60/32bit')
    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

    Anyway, looking at your log it seems like picking up java from /QIBM/ProdData/Java400/jdk6

    as shown in the log by this line
    > Attaching Java program to /QIBM/ProdData/Java400/jdk6/lib/charsets.jar.

    Try changing the export of JAVA_HOME to

    export -s JAVA_HOME=/QOpenSys/QIBM/ProdData/JavaVM/jdk60/32bit

    ReplyDelete
  9. Hi.
    Do you know how to connect to db2 on linux through jdbc from a tomcat installation on system I ? when i try with the war unmodified i get an error: "not in relational database" error.
    On trying to access the database from tomcat this error is trown.. com.ibm.db2.jdbc.app.DB2SQLSyntaxErrorException: Relational database 1.2.3.4 not in relational database directory.
    The driver is setup as follows: com.ibm.db2.jcc.DB2
    Driver connection string: jdbc:db2://1.2.3.4:50003/DB

    ReplyDelete