You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Mladen Turk <mt...@mappingsoft.com> on 2002/09/18 18:40:46 UTC

[BUG] jk2 jni doesn't work

OK this is a release showstopper!

Now I'm convinced that JNI doesn't work as it should :(
Done some serious tests with various JDK's and TC versions from 4.0.4
through 4.1.10

The jni works _only_ and ONLY if preceded by socket call meaning
[channel.socket]
[channel.jni]
works, but
[channel.jni]
[channel.socket]
doesn't work

I've traced the problem down to the MsgAjp constructor called from
JniHandler's createMsgContext member:

...
    public MsgContext createMsgContext() {
        if( nativeJkHandlerP==0 || apr==null  )
            return null;

        try {
            MsgContext msgCtx=new MsgContext();
// THIS IS PASSED
            System.err.println("JniHandler OK createMsgContext
MsgContext");
            
            MsgAjp msg=new MsgAjp();
// NEWER GETS HERE
            System.err.println("JniHandler OK createMsgContext MsgAjp");
....
        
	} catch( Exception ex ) {
// DISPLAYS NOTHING!            
            ex.printStackTrace();
            return null;
        }
 ...


IMHO the reason is missing org.apache.commons.logging.LogFactory,
perhaps not loaded by the jni channel.
If someone more familiar with that can dig into and trace the problem it
would be great, or I'll simply delete all that 'unnecessary' *.Log
stuff, and use the System.err.

MT.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [BUG] jk2 jni doesn't work

Posted by jean-frederic clere <jf...@fujitsu-siemens.com>.
Mladen Turk wrote:
> 
>>-----Original Message-----
>>From: jean-frederic clere 
>>
>>OPT=-Djava.class.path=${TOMCAT_HOME}\bin\tomcat-jni.jar;${TOMCAT_HOME}
>>
>>>\s
>>>erver\lib\commons-logging.jar
>>
>>I do not like this work-around: we will have end with a huge 
>>classpath.
>>
> 
> 
> Neither do I, but this is the only way for now to be able to use the JNI
> at all. If the JkMain or TomcatStarter loads the commons-logging at
> first place we wouldn't have this problem.
> I've added the LogFactory to the AprImpl that reports the error on TC
> startup from inprocess and fails to start if the commons-logging is
> missing, cause JNI wouldn't work properly at the first place without it.
> So, fixing classloader is a showstopper on any jk2 release, and as I
> said it is only a workaround that will disappear once that is fixed.

Adding a classloader that loads in ${TOMCAT_HOME}/bin is my idea but I need time 
to do it (I am fighting with daemon in a BS2000).

> 
> 
> MT.
> 
> 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [BUG] jk2 jni doesn't work

Posted by Mladen Turk <mt...@mappingsoft.com>.

> -----Original Message-----
> From: jean-frederic clere 
> > 
> OPT=-Djava.class.path=${TOMCAT_HOME}\bin\tomcat-jni.jar;${TOMCAT_HOME}
> > \s
> > erver\lib\commons-logging.jar
> 
> I do not like this work-around: we will have end with a huge 
> classpath.
>

Neither do I, but this is the only way for now to be able to use the JNI
at all. If the JkMain or TomcatStarter loads the commons-logging at
first place we wouldn't have this problem.
I've added the LogFactory to the AprImpl that reports the error on TC
startup from inprocess and fails to start if the commons-logging is
missing, cause JNI wouldn't work properly at the first place without it.
So, fixing classloader is a showstopper on any jk2 release, and as I
said it is only a workaround that will disappear once that is fixed.


MT.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [BUG] jk2 jni doesn't work

Posted by jean-frederic clere <jf...@fujitsu-siemens.com>.
Mladen Turk wrote:
> This is the classloader problem.
> 
> Think that Bill Baker is solving this, but until then add the
> commons-logging.jar to the loaded classes when started inprocess:
> 
> OPT=-Djava.class.path=${TOMCAT_HOME}\bin\tomcat-jni.jar;${TOMCAT_HOME}\s
> erver\lib\commons-logging.jar

I do not like this work-around: we will have end with a huge classpath.

> 
> Adding commons-logging to the classpath solves the JNI problem.
> 
> Bill, when can ve expect this will get solved?
> 
> 
> 
> 
>>java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
>>	at org.apache.jk.apr.AprImpl.<clinit>(AprImpl.java:348)
>>java.lang.NoClassDefFoundError
>>
>>
> 
> 
> MT.
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [BUG] jk2 jni doesn't work

Posted by Mladen Turk <mt...@mappingsoft.com>.
This is the classloader problem.

Think that Bill Baker is solving this, but until then add the
commons-logging.jar to the loaded classes when started inprocess:

OPT=-Djava.class.path=${TOMCAT_HOME}\bin\tomcat-jni.jar;${TOMCAT_HOME}\s
erver\lib\commons-logging.jar

Adding commons-logging to the classpath solves the JNI problem.

Bill, when can ve expect this will get solved?



> 
> java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
> 	at org.apache.jk.apr.AprImpl.<clinit>(AprImpl.java:348)
> java.lang.NoClassDefFoundError
> 
> 

MT.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [BUG] jk2 jni doesn't work

Posted by Mladen Turk <mt...@mappingsoft.com>.
> -----Original Message-----
> From: Mladen Turk [mailto:mturk@mappingsoft.com] 
> 
> 
> OK this is a release showstopper!
> 
> 
> IMHO the reason is missing org.apache.commons.logging.LogFactory,
> perhaps not loaded by the jni channel.
> If someone more familiar with that can dig into and trace the 
> problem it would be great, or I'll simply delete all that 
> 'unnecessary' *.Log stuff, and use the System.err.
> 

Perhaps this will help:

I've added the following to the AprImpl.java


import org.apache.commons.logging.*;

public class AprImpl extends JkHandler {
...

    private static Log log = LogFactory.getLog( AprImpl.class );

}

And On starting TC I'm getting the following in the error.log:

java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
	at org.apache.jk.apr.AprImpl.<clinit>(AprImpl.java:348)
java.lang.NoClassDefFoundError


MT.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>