iSeries V7R1 MOD_JK AJP connector for Tomcat urgent issue - Need help

I have several installs where I am using Tomcat behind Apache to host my web applications. But in the past month I realized that IBM has stopped giving us the jk_module as a part of the install. Their reason is that they no longer support Tomcat but I don't understand why take away the bridge.

I am able to run the Tomcat 6.0 without any issue on the IBM i. I tried to build the MOD_JK from source but the compilation fails. Here is the error

/home/apache/jk/native/apache-2.0/mod_jk.c, 75.10: CZM0296(30) #include
file "unixd.h" not found.

(if you know how to get that C library unixd.h on the iSeries, please let me know)

So I looked into the source for mod_jk.c and commented out the line that tells it to include the unixd.h file. Here is the code snippet.


#ifdef AP_NEED_SET_MUTEX_PERMS
/* I have commented the following line */
/*# define JK_NEED_SET_MUTEX_PERMS AP_NEED_SET_MUTEX_PERMS*/
#else
......
......
/* I have added this line to define the variable */
# define JK_NEED_SET_MUTEX_PERMS 0

After that I could compile my MOD_JK module and create the service program. Then changed the httpd.conf from

LoadModule jk_module /QSYS.LIB/QHTTPSVR.LIB/QZTCJK.SRVPGM
to
LoadModule jk_module /QSYS.LIB/QHTTPSVR.LIB/MOD_JK.SRVPGM

But that too gives me errors during the Apache server startup. Here is the error.
Message . . . . : Error occurred converting data. Reason 4.
Cause . . . . . : An error occurred converting data between UTF8 and an EBCDIC CCSID.

There is a fix for this that I found in the information center.

Setting up third party modules for HTTP Server (powered by Apache)

As of i5/OS™ V5R4, modules must be recompiled with a UTF locale. This creates an environment where locale-dependent C runtime functions assume that string data is encoded in UTF-8. Any hardcoded constants can be encoded in UTF-8 by adding a #pragma convert(1208) statement in the module. Additionally, input data from the client will no longer be converted to EBCDIC but will be passed as-is. Output data sent from the module is not converted either so it must be encoded in ASCII or UTF8 as required. APR and HTTP APIs as of V5R4, expect data in UTF-8. Note that several APIs have additional functions that allow a CCSID to be set to indicate the encoding of the parameters being passed. Conversion functions between UTF-8 and EBCDIC have been added. Be sure to review APIs used by your module to be aware of current changes.

Follow the below directions to compile and use a new module.

1. Save the source code
Save the source code in your QSYS or IFS directory. All objects created from compiling and creating the service program must be placed in the QSYS directory.

2. Compile the source code
Compile the source code using the CRTCMOD command. Before you compile the program, make sure you have the correct programming language compiler installed on your iSeries™ (the most common programming language used is C). Replace the text in the parenthesis ( ) with your own information.
CRTCMOD MODULE(Destination module name and library for the compiled module object.) 
Any Apache modules will need to be changed in order to run as a UTF-8 based server module as opposed to an EBCDIC based server module.
  • For ILE C use:
    CRTCMOD MODULE(MYLIB/MOD_TEST) SRCSTMF('/mydir/mymodule/source/mod_test.c')
    DEFINE(AS400 AS400_UTF8) LOCALETYPE(*LOCALEUTF) TERASPACE(*YES)
    INCDIR('/qibm/proddata/httpa/include')
  • For C++ use:
    CRTCPPMOD MODULE(MYLIB/MOD_TEST) SRCSTMF('/mydir/mymodule/source/mod_test.c') 
    DEFINE(AS400 AS400_UTF8) LOCALETYPE(*LOCALEUTF) TERASPACE(*YES) 
    INCDIR('/qibm/proddata/httpa/include') 
Notice the change in the LOCALETYPE parameter. Using LOCALETYPE(*LOCALEUTF) does the following: Program objects created with this option use the locale support provided by *LOCALE objects. Wide-character types contain four-byte UTF-32 values. Narrow character types contain UTF-8 values. The effect of this change enables the locale dependent C runtime functions to work on UTF-8 strings.

So I Changed the source for BLDJK for all the CRTCMOD. Here is a snippet
CRTCMOD    MODULE(MOD_JK/MOD_JK) +                          
             SRCSTMF('/home/apache/jk/native/apache-2.0/+   
             mod_jk.c') TEXT('mod_jk.c') OPTIMIZE(40) +     
             DEFINE('AS400' 'HAVE_JNI' 'HAVE_APR' +         
             '_XOPEN_SOURCE=520' 'USE_APACHE_MD5' +         
             '_REENTRANT' 'AS400_UTF8') +                   
             LANGLVL(*EXTENDED) SYSIFCOPT(*IFSIO) +         
             LOCALETYPE(*LOCALEUTF) TGTRLS(*CURRENT) +      
             INCDIR('/home/apache/jk/native/common' +       
             '/QIBM/ProdData/HTTPA/Include')                

Again I compiled everything and started the Apache Server, but it still fails. Any help !
Here is the error that I get and this time its in the JK log file.

[error] mod_jk.c (3236): Initializing shm:/www/test/logs/jk-runtime-status.19533 errno=34440.
Load balancing workers will not function properly.

I tried the Tomcat as Proxy but it fails on some pages not getting rendered properly. Showing source on the page ....


No comments:

Post a Comment

NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.