Friday, July 20, 2007

Back to Java. Having fun connecting to Tuxedo server with JNI.

It's been two years since I left mainstream Java programming. I have been working with IBM Interchange Server (a.ka Crossworlds) and more recently with Process Server. However, my new project is all about good old J2EE. After two weeks of JAD sessions, one month of design, and one month of detailed design, I have embarked on coding this simple web-services application along with few talented and motivated folks here and offshore. So far so good, except for the critically-ill item of the project - creating an instance of work flow in Bea Tuxedo from a WAS application server using Java-Native interface.

Getting JNI to work on AIX has been my sole agenda for last 3 days. Ofcourse, I am not talking about a HelloWorld example. May be a HelloWorld example would have saved me a day in the process.

Coming to the point here what I have learned:

1) System.loadLibrary("LirbaryWithoutExtension") will load the Library from java.library.path. And java.library.path is initialized by JVM with some lib and bin folders within JAVA_HOME and whatever directories are set in LIBPATH(AIX)/LD_LIBRARY_PATH(UNIX/Solaris) /PATH(Windows).

2) In WebSphere Application Server (WAS), Process Definition section is capable of exporting system variables, typically required by the native libraries (.so / .dll). And in the same section, we can define LIBPATH/LD_LIBRARY_PATH. In WSAD in the server settings /Environment, we can add java.library settings.

3) -Xj9 is used to enable fast-jvm instead of classic jvm.

4) -Xcheck:jni:nonfatal is used to avoid jvm-abort in the case of nonfatal errors during JNI.

5) JNI Verbose option in WebSphere Admin console has been useful to understand exact error messages while making JNI calls.

More later.