IBM Support

How to build Tomcat plug-in mod_jk on IBM i

News


Abstract

There is an article discusses how to bring Tomcat to IBM i, associate Tomcat with HTTP Server for i, which helps us to have a basic understanding of how to install and run Tomcat on IBM i. In that article, the Tomcat plug-in QZTCJK is provided by IBM i, which is based on an old version mod_jk. It does not include recent new features supported and will not be upgraded by IBM anymore.
This article introduces how to compile, build, and use the latest version of open source Tomcat plug-in mod_jk on IBM i 7.2 and above.

Content

Below steps show how to get the latest version mod_jk source code and compile, build it on IBM i server.

Step 1, Download mod_jk source code

Download the latest version source code (JK 1.2.48 Source Release tar.gz) from Apache Tomcat website http://tomcat.apache.org/download-connectors.cgi and the current latest version is JK 1.2.48.

Step 2, FTP the source code to IBM i

FTP the source code package to IBM i server and unzip it to an IFS directory: /home/apache/jk like below structure:

image 12411

Step 3, Update the build file for IBM 7.2 and later

We need to copy the new build file bldjkibmi.qclsrc(attached below) to /home/apache/jk/native/apache-2.0 directory due to the large file support feature is enabled by HTTP Server on IBM i 7.2 and later.

Note:  If you exact your source code to other directories in step 1, you also need to update the build file accordingly to change the path of source code.

Step 4, Apply code patch

There is a flaw in the source code of tomcat-connectors v1.2.39 and later, which needs to be fixed in order to get the mod_jk successfully complied and build on IBM i(See the bottom of the patch).  

If we use the default source code to compile and build mod_jk, HTTP Server fails to start with below errors in job logon IBM i.

 MCH3601 Escape 40 07/17/14 21:51:39.069163 QZSRAPR QHTTPSVR *STMT QZSRAPR QHTTPSVR *STMT

                                      From module . . . . . . . . :   APR_POOLS                                                     

                                      From procedure  . . . . . . :   allocator_free    

                                      Statement . . . . . . . . . :   8                                                             

                                      To module . . . . . . . . . :   APR_POOLS                                                    

                                      To procedure  . . . . . . . :   allocator_free                                                

                                      Statement . . . . . . . . . :   8                                                            

                                      Message . . . . :   Pointer not set for location referenced.                                  

                                      Cause . . . . . :   A pointer was used, either directly or as a basing 

The patch also includes a fix for this. Apply the patch jk_connect.patch (attached below) before compiling the source code.

Step 5, Create mod_jk library

 CRTLIB MOD_JK TEXT('Apache mod jk Tomcat connector module')

Step 6, Create service program source file

CRTSRCPF MOD_JK/QSRVSRC TEXT('Service program source file')

Step 7, Create the CL build program source file

CRTSRCPF FILE(MOD_JK/QCLSRC) TEXT('Build program source file')

Step 8, Edit the service program source file

STRSEU MOD_JK/QSRVSRC MOD_JK

SEU==>

*************** Beginning of data *************************************

               STRPGMEXP PGMLVL(*CURRENT)

               EXPORT SYMBOL("jk_module")

               ENDPGMEXP

****************** End of data ****************************************

Step 9, Copy the CL build program source for IBM i from IFS

CPYFRMSTMF FROMSTMF('/home/apache/jk/native/apache-2.0/bldjkibmi.qclsrc') TOMBR('/QSYS.LIB/MOD_JK.LIB/QCLSRC.FILE/BLDJKIBMI.MBR') MBROPT(*REPLACE)

Step 10, Build the CL build program for IBM i

CRTCLPGM PGM(MOD_JK/BLDJKIBMI) SRCFILE(MOD_JK/QCLSRC) TEXT('Apache mod_jk build program') TGTRLS(*CURRENT)

Step 11, Launch the build for IBM i

CALL MOD_JK/BLDJKIBMI

Step 12, Copy mod_jk to QHTTPSVR library and grant correct authority

If the mod_jk is successfully built in step 11,  optionally, we can copy it to HTTP Server library QHTTPSVR and grant correct authority so it can be loaded by HTTP Server for i.

CRTDUPOBJ OBJ(MOD_JK) FROMLIB(MOD_JK) OBJTYPE(*SRVPGM) TOLIB(QHTTPSVR) NEWOBJ(MOD_JK)

Change the object authority of /QSYS.LIB/QHTTPSVR.LIB/MOD_JK.SRVPGM like below:

image 12418

Step 13,  Start HTTP Server to test

Follow the previous article to install Tomcat and setup HTTP Server on i, the only change is using the new built Tomcat plug-in LoadModule jk_module /QSYS.LIB/QHTTPSVR.LIB/MOD_JK.SRVPGM to replace the old IBM Tomcat plug-in LoadModule jk_module /QSYS.LIB/QHTTPSVR.LIB/QZTCJK.SRVPGM in the httpd.conf.

Start HTTP Server and access Tomcat home page to test. In the jk.log, you can see the new built Tomcat plug-in is loaded:

[info] mod_jk.c (3383): mod_jk/1.2.48 initialized 

Resources

[1] http://tomcat.apache.org/download-connectors.cgi

Attachment

 bldjkibmi.qclsrc.txt

jk_connect.patch.txt

[{"Type":"MASTER","Line of Business":{"code":"","label":""},"Business Unit":{"code":"","label":""},"Product":{"code":"SSB2FF","label":"HTTP Server for i"},"ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]

Document Information

Modified date:
30 November 2021

UID

ibm16520356