You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Rahul Bhargava <co...@hotmail.com> on 2003/02/11 20:34:03 UTC

JNI broken in jk2 - due to jk2_channel_jni_open()

There is no way in hell JNI can ever work with JK2.  jk_channel_jni.c::jk2_channel_jni_open invokes
the java static method createJavaContext() which in turns tries to return a registered JkHandler for
Jni (ChannelJni) from the underlying hashtable. However when the in-process mode is enabled, there
is nobody registering any handlers! As a result null is trurned into c land from Java when createJavaContext
returns causing the JNI invocation to fail.

Tried this with Apache 2.0.43/44. With the out of process mode the declaration in server.xml cause a JkCoyoteHandler to be registered but with the in-process mode, this was suppose to happen automatically. Nobody seems to trigger a call to AprImpl.addJkHandler() - not in java land not in c land!

This convince me that JNI mode never really worked with JK2. If you look at the tomcat-user archive
you can see people falling on their faces trying to get this to work,but nobody has succedded now
I know why.

Someone should fix the Jk2 web site which lures naive users to believe that JNI mode is working with
Jk2! I did try to fix the problem by tring to instantiate a ChannelJni instance in the ctor of AprImpl and register
it into the jkHandlers table but  was getting NPE...don't know the code that well to know what assumptions are built into ChannelJni. Will continue to debug. 
_________________________________
Rahul Bhargava

RE: JNI broken in jk2 - due to jk2_channel_jni_open()

Posted by mt...@mappingsoft.com.

> -----Original Message-----
> From: Rahul Bhargava [mailto:coderobo@hotmail.com]
> Sent: 11. veljača 2003 20:34
> To: tomcat-dev@jakarta.apache.org
> Subject: JNI broken in jk2 - due to jk2_channel_jni_open()
> 
> There is no way in hell JNI can ever work with JK2.
> jk_channel_jni.c::jk2_channel_jni_open invokes
> the java static method createJavaContext() which in turns tries to
return
> a registered JkHandler for
> Jni (ChannelJni) from the underlying hashtable. However when the in-
> process mode is enabled, there
> is nobody registering any handlers! As a result null is trurned into c
> land from Java when createJavaContext
> returns causing the JNI invocation to fail.
> 

The jni channel is initialized from inside AprImpl. That is where all
the java-native stuff is done and initialized.
Also that imposes some problems, and one of them is missing LogFactory
class from commons-logging.
All you have to do is to add the commons-logging to the TC's startup
classpath.

Here is the snippet from the _original_ workers2.properties:

[vm:]
....
classpath=${TOMCAT_HOME}/bin/tomcat-jni.jar
classpath=${TOMCAT_HOME}/server/lib/commons-logging.jar
....

So, you'll need both classes preloaded to be able to use the JNI.


> 
> This convince me that JNI mode never really worked with JK2. If you
look
> at the tomcat-user archive
> you can see people falling on their faces trying to get this to
work,but
> nobody has succedded now
> I know why.
>

Just follow the:

http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jk2/jk2/confighowto.html

You have the minimum JNI configuration section there, except that you
should replace the classpath directive with the above two lines.

MT.



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org