You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Alexander Leyke <al...@cs.com> on 2002/11/19 18:58:52 UTC

JK2 module for AOLserver

Hello!

I am working on a JK2 module for AOLserver and would like to receive 
feedback on JNI and compiler issues I encountered. My environment is 
Solaris 7, AOLserver 3.4 and Tomcat 4.1.12. Issues:

1) Can't use JNI worker. AOLserver follows single-process, 
multi-threaded architectural model and its native scripting language is 
Tcl. Executing servlets in-process would help to bridge a gap between 
Java and Tcl and so is an important motivation in this project. My 
module loads JVM and initializes Tomcat in-process, but then I encounter 
2 conditions:

"ajp13" worker factory seems to be hardcoded regardless of actual worker 
type. Here is a snippet from JTC-4.1.12/jk/native2/common/jk_workerEnv.c:

static int jk2_workerEnv_addChannel(jk_env_t *env, jk_workerEnv_t *wEnv,
                                    jk_channel_t *ch)
{
    ...
    /* Automatically create the ajp13 worker to be used with this channel.
     */
    jkb=env->createBean2(env, ch->mbean->pool, "ajp13", 
ch->mbean->localName );
    ...
}

I changed the code above to use "ajp13" or "worker.jni" depending on 
ch->mbean->localName , but that still didn't help, because 
jk2_jni_worker_service function in 
JTC-4.1.12/jk/native2/common/jk_worker_jni.c is a placeholder. I did 
make sure not to use default "lb" worker for JNI.

Is JNI worker intentionally disabled, or am I misinterpreting the code? 
I could fix jk2_jni_worker_service function with some guidance, but is 
there a similar implementation gap in Tomcat 4 Java classes?

2) JTC build doesn't seem to be very friendly for non-GNU compilers. I 
use Sun Workshop, and had to write some hacks to make ant and libtool 
work with Sun's C compiler. In particular, both ant and libtool insisted 
on supplying invalid "-W" command option to compiler. I suspect that 
JTC-4.1.12/jk/jkant/java/org/apache/jk/ant/compilers/CcCompiler.java is 
intended for UCB cc support, and I need to write a separate class for 
ant to work with Sun's cc and bypass libtool (which configured itself 
mostly correctly to use Sun cc, but still insisted on "-W"). Had anyone 
had any relevant experience?

Thanks very much!

Alex Leykekh
Sr. Software Engineer, AOL Digital City


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


Re: JK2 module for AOLserver

Posted by Costin Manolache <cm...@yahoo.com>.
Alexander Leyke wrote:

> 
> 
> Costin Manolache wrote:
> 
>>Are you using the jni channel ? Is that working too ?
>>  
>>
> No, it is the default ajp13 channel. I think I told you about my doubts
> about jk_workerEnv.c hardcoding "ajp13" as the type for all channel
> initialization. Anyway, this is how the code looks like now (let me know
> if I am missing the point here). Would the code I have commented out use
> jni channel?

I don't think so.

AFAIK jni uses the ajp13 protocol over jni channel.
All you have to do is define the config:

In workers2.properties:
 [channel.jni:jni]
 info=The jni channel, used if tomcat is started inprocess
 debug=10

 
[worker.jni:jniCmd1]
 info=Command to be executed by the VM. This one will start tomcat.
 class=org/apache/jk/apr/TomcatStarter
 ARG=start
 debug=10
 
 [uri:/... ]
 worker=jni

The moment you define the channel.jni stuff it'll create automatically a 
worker with the same name, and you can map to that worker.
( the worker will be of ajp13 type - but use the jni channel ).

( yes, I know - we need more documentation ).



>>Regarding jsp - it uses ant to compile, so you may want to set a
>>system property to specify the compiler ( you can do it in the worker
>>config ). I use "build.compiler=jikes" :-)
>>  
>>
> Not sure how the things are related to ant. Standalone Tomcat compiles
> JSP perfectly well, so I think this is related to runtime environment,
> some option missing from in-process environment. Isn't ant used strictly
> at build time, and JSP compile done by Tomcat translating things to Java
> and then calling JVM to compile into bytecode?

Tomcat4.1 uses javac task from ant to compile. ( no build file - it embeds
it ). That means any settings from ant would work. ( ant is pretty good at
compiling - the idea was to avoid duplicating this ).



> I think there is a 4th phase, shutdown. What does servlet spec say about
> shutdown, is there a way to register a "shutdown" servlet - loosing that
> capability may not be the best thing. I do see slightly different
> behavior now - there is a "Service shutting down" message from Tomcat,
> but AOLserver shutdown messages are missing. It could be bugs in my
> code, I know I forgot to initialize JVM in separate thread (has to do
> with AOLserver disabling signals in main thread, and JVM depending on
> them to do garbage collection).

Tomcat registeres a shutdown hook ( with JDK1.3+ I think ).
I think Mladen added shutdown hooks - but I never tested this.

Costin





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


Re: JK2 module for AOLserver

Posted by Alexander Leyke <al...@cs.com>.

Costin Manolache wrote:

>Are you using the jni channel ? Is that working too ? 
>  
>
No, it is the default ajp13 channel. I think I told you about my doubts 
about jk_workerEnv.c hardcoding "ajp13" as the type for all channel 
initialization. Anyway, this is how the code looks like now (let me know 
if I am missing the point here). Would the code I have commented out use 
jni channel?

static int jk2_workerEnv_addChannel(jk_env_t *env, jk_workerEnv_t *wEnv,
                                    jk_channel_t *ch)
{
    ...
    /* Automatically create the ajp13 worker to be used with this channel.
     */
    jkb=env->createBean2(env, ch->mbean->pool, "ajp13", 
ch->mbean->localName );

    /* AL - attempt to change to different channel

    if (strcmp (ch->mbean->localName, "jni") == 0)
        factype = "worker.jni";
    else
        factype = "ajp13";

    */
    ...

>
>Regarding jsp - it uses ant to compile, so you may want to set a 
>system property to specify the compiler ( you can do it in the worker
>config ). I use "build.compiler=jikes" :-)
>  
>
Not sure how the things are related to ant. Standalone Tomcat compiles 
JSP perfectly well, so I think this is related to runtime environment, 
some option missing from in-process environment. Isn't ant used strictly 
at build time, and JSP compile done by Tomcat translating things to Java 
and then calling JVM to compile into bytecode?

>You can have hooks for startup, init, or close - but the only one that
>matters ( in most cases ) is the one that loads main().
>  
>
I think there is a 4th phase, shutdown. What does servlet spec say about 
shutdown, is there a way to register a "shutdown" servlet - loosing that 
capability may not be the best thing. I do see slightly different 
behavior now - there is a "Service shutting down" message from Tomcat, 
but AOLserver shutdown messages are missing. It could be bugs in my 
code, I know I forgot to initialize JVM in separate thread (has to do 
with AOLserver disabling signals in main thread, and JVM depending on 
them to do garbage collection).

Thank you,
Alex


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


Re: JK2 module for AOLserver

Posted by Costin Manolache <cm...@yahoo.com>.
Alexander Leyke wrote:

>>I used BootstrapService because it didn't create the 8005 shutdown
>>socket. My tests were done with 4.0.
>>You can create your own wrapper, use CatalinaService directly or
>>call Bootstrap ( if you don't mind 8005 - in your case it doesn't
>>matter too much since you'll have a single process ).
>>  
>>
> Bootstrap just worked for me <sigh of relief>. Comments in
> BootstrapService.java suggest it is for Win32. Are you testing on NT? I
> am still getting Java exceptions and for some reason javac doesn't want
> to compile (it cannot find "modern" compiler and is looking for
> "classic"), but JSP I had compiled before are running.

Are you using the jni channel ? Is that working too ? 

Regarding jsp - it uses ant to compile, so you may want to set a 
system property to specify the compiler ( you can do it in the worker
config ). I use "build.compiler=jikes" :-)



> I saw the code which sends the message. Looks like it just disables
> hooks that don't belong to startup, init, or close phase. I am not sure
> what implications it has.

You can have hooks for startup, init, or close - but the only one that
matters ( in most cases ) is the one that loads main().

Costin



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


Re: JK2 module for AOLserver

Posted by Alexander Leyke <al...@cs.com>.
Costin Manolache wrote:

>I used BootstrapService because it didn't create the 8005 shutdown
>socket. My tests were done with 4.0. 
>You can create your own wrapper, use CatalinaService directly or
>call Bootstrap ( if you don't mind 8005 - in your case it doesn't
>matter too much since you'll have a single process ).
>  
>
Bootstrap just worked for me <sigh of relief>. Comments in 
BootstrapService.java suggest it is for Win32. Are you testing on NT? I 
am still getting Java exceptions and for some reason javac doesn't want 
to compile (it cannot find "modern" compiler and is looking for 
"classic"), but JSP I had compiled before are running.

>  
>
>>A related question - what does this log entry mean? I think it is
>>related to [worker.jni:onShutdown] entry in workers2.properties.
>>
>>jk_worker_jni.c:369:jni.init() disabling the non init hook worker
>>    
>>
>
>I have no idea. Ask Mladen :-) 
>
>I know he added special code to allow multiple classes to be called
>on startup, init, shutdown, etc. There are several ways to 
>load the java class. 
>
>Since you see the messages from TomcatStarter - I assume it's 
>harmless.
>
>  
>
I saw the code which sends the message. Looks like it just disables 
hooks that don't belong to startup, init, or close phase. I am not sure 
what implications it has.

Thanks!
Alex


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


Re: JK2 module for AOLserver

Posted by Costin Manolache <cm...@yahoo.com>.
Alexander Leyke wrote:

>>You can configure a different starter ( TomcatStarter did work
>>with an older version of BootstrapService - now you can't use
>>the 4.1 version of BS without daemon ). You can probably try
>>to just configure it to use o.a.catalina.startup.Bootstrap.
>>( or a different starter with a main() )
>>  
>>
> I see o.a.jk.apr.TomcatStarter.main() call
> o.a.catalina.startup.BootstrapService.main(). I didn't think of changing
> the bootstrap class. I see the followin "candidates":
> 
> org/apache/catalina/startup/Bootstrap.class
> org/apache/catalina/startup/BootstrapService.class
> org/apache/catalina/startup/CatalinaService.class
> org/apache/catalina/startup/Catalina.class
> org/apache/catalina/startup/Embedded.class
> 
> Unfortunately the link to Catalina Javadocs off is broken on the
> jakarta.apache.org Website. I'll browse through the Java sources,
> butwould be helpful if anyone could mention which bootstrap class I
> could use in place of TomcatStarter

I used BootstrapService because it didn't create the 8005 shutdown
socket. My tests were done with 4.0. 
You can create your own wrapper, use CatalinaService directly or
call Bootstrap ( if you don't mind 8005 - in your case it doesn't
matter too much since you'll have a single process ).


> A related question - what does this log entry mean? I think it is
> related to [worker.jni:onShutdown] entry in workers2.properties.
> 
> jk_worker_jni.c:369:jni.init() disabling the non init hook worker

I have no idea. Ask Mladen :-) 

I know he added special code to allow multiple classes to be called
on startup, init, shutdown, etc. There are several ways to 
load the java class. 

Since you see the messages from TomcatStarter - I assume it's 
harmless.


> 
>>>::::::::::::::
>>>stderr.log
>>>::::::::::::::
>>>TomcatStarter: main()
>>>Try  org.apache.tomcat.startup.Main
>>>Try  org.apache.catalina.startup.BootstrapService
>>>Starting org.apache.catalina.startup.BootstrapService
>>>java.lang.NullPointerException
>>>        at
>>>        
org.apache.catalina.startup.BootstrapService.start(BootstrapService.java:244)
>>>    
>>>
>>>        at
>>>        
org.apache.catalina.startup.BootstrapService.main(BootstrapService.java:307)
>>>    
>>>
>>>        at java.lang.reflect.Method.invoke(Native Method)
>>>        at org.apache.jk.apr.TomcatStarter.run(TomcatStarter.java:127)
>>>        at java.lang.Thread.run(Thread.java:484)
>>>Created catalinaLoader in: /<deleted -
>>>AL>/jakarta-tomcat-4.1.12/server/lib
>>>[INFO] Registry - -Loading registry information
>>>[INFO] Registry - -Creating new Registry instance
>>>[INFO] Registry - -Creating MBeanServer
>>>[INFO] Http11Protocol - -Initializing Coyote HTTP/1.1 on port 8089
>>>java.lang.ArrayIndexOutOfBoundsException
>>>        at
>>>        
org.apache.catalina.startup.BootstrapService.main(BootstrapService.java:305)
>>>    
>>>
>>>        at java.lang.reflect.Method.invoke(Native Method)
>>>        at org.apache.jk.apr.TomcatStarter.run(TomcatStarter.java:127)
>>>        at java.lang.Thread.run(Thread.java:484)
>>>java.lang.ArrayIndexOutOfBoundsException
>>>        at org.apache.jk.apr.TomcatStarter.run(TomcatStarter.java:131)
>>>        at java.lang.Thread.run(Thread.java:484)
>>>::::::::::::::
>>>stdout.log
>>>::::::::::::::
>>>Bootstrap: Starting service
>>>TomcatStarter: Done
>>>TomcatStarter: Done
>>>    
>>>
>>
>>  
>>




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


Re: JK2 module for AOLserver

Posted by Alexander Leyke <al...@cs.com>.

Costin Manolache wrote:

>In jk2, all those strings are eliminated ( from C side ), we also eliminate
>the buffer allocation ( we reuse the same jbyteArray and C array, with
>code to eventually support NIO - that cuts 2 memcpy and few other small
>things ). We also reduce the number of JNI calls to a minimum ( or almost ).
>
>Regarding the single-threaded behavior - I think this is a major benefit
>for JNI ( or doors ) workers, since it can avoid thread switching and a lot
>of synchronization. In all other protocol there are 2 threads sending data
>to each other. This won't be visible for a small number of RPS, but 
>I expect it to be important for very high loads. Well - most likely this
>is just a benchmarking exercise - if the servlets are doing anything usefull
>they'll dominate the execution time anyway, the connector overhead is 
>already extremely small.
>
>  
>
Ah! I understand now what you meant by "single-threaded". It does sound 
like a better option.

>You just need to port the nstomcat module to jk2. 
>
>jk1 doesn't support tomcat4 in-process, jk2 does. From the connector
>point of view it doesn't matter what tomcat is run ( at one point
>it even detected the tomcat version at runtime - all it cares is to
>have coyote/jk2 available and have a class with main() ).
>
>  
>
Exactly what I am doing. I have all AOLserver JK2 C code (simingly!) in 
place, and after fixing some things in workers2/jk2.properties I can see 
the worker attempt to communicate with AJP connector on port 8009:

jk_channel_socket.c:328:channelSocket.open() connect failed 
localhost:8009 146 Connection refused

I think above is due to Tomcat failing to initialize properly when 
in-process. It does listen on 8009 when I launch it from command line.

>Did you get the connector to work with sockets ? ( i.e tomcat out
>of process ) ? That's the first step, you need this to work well
>to test the aol-specific code. 
>  
>
Yes. Works perfectly well, leaves nothing suspicious in the logs.

>You can configure a different starter ( TomcatStarter did work 
>with an older version of BootstrapService - now you can't use
>the 4.1 version of BS without daemon ). You can probably try
>to just configure it to use o.a.catalina.startup.Bootstrap.
>( or a different starter with a main() )
>  
>
I see o.a.jk.apr.TomcatStarter.main() call 
o.a.catalina.startup.BootstrapService.main(). I didn't think of changing 
the bootstrap class. I see the followin "candidates":

org/apache/catalina/startup/Bootstrap.class
org/apache/catalina/startup/BootstrapService.class
org/apache/catalina/startup/CatalinaService.class
org/apache/catalina/startup/Catalina.class
org/apache/catalina/startup/Embedded.class

Unfortunately the link to Catalina Javadocs off is broken on the 
jakarta.apache.org Website. I'll browse through the Java sources, 
butwould be helpful if anyone could mention which bootstrap class I 
could use in place of TomcatStarter

A related question - what does this log entry mean? I think it is 
related to [worker.jni:onShutdown] entry in workers2.properties.

jk_worker_jni.c:369:jni.init() disabling the non init hook worker

Thanks,
Alex


>>::::::::::::::
>>stderr.log
>>::::::::::::::
>>TomcatStarter: main()
>>Try  org.apache.tomcat.startup.Main
>>Try  org.apache.catalina.startup.BootstrapService
>>Starting org.apache.catalina.startup.BootstrapService
>>java.lang.NullPointerException
>>        at org.apache.catalina.startup.BootstrapService.start(BootstrapService.java:244)
>>    
>>
>>        at org.apache.catalina.startup.BootstrapService.main(BootstrapService.java:307)
>>    
>>
>>        at java.lang.reflect.Method.invoke(Native Method)
>>        at org.apache.jk.apr.TomcatStarter.run(TomcatStarter.java:127)
>>        at java.lang.Thread.run(Thread.java:484)
>>Created catalinaLoader in: /<deleted -
>>AL>/jakarta-tomcat-4.1.12/server/lib
>>[INFO] Registry - -Loading registry information
>>[INFO] Registry - -Creating new Registry instance
>>[INFO] Registry - -Creating MBeanServer
>>[INFO] Http11Protocol - -Initializing Coyote HTTP/1.1 on port 8089
>>java.lang.ArrayIndexOutOfBoundsException
>>        at org.apache.catalina.startup.BootstrapService.main(BootstrapService.java:305)
>>    
>>
>>        at java.lang.reflect.Method.invoke(Native Method)
>>        at org.apache.jk.apr.TomcatStarter.run(TomcatStarter.java:127)
>>        at java.lang.Thread.run(Thread.java:484)
>>java.lang.ArrayIndexOutOfBoundsException
>>        at org.apache.jk.apr.TomcatStarter.run(TomcatStarter.java:131)
>>        at java.lang.Thread.run(Thread.java:484)
>>::::::::::::::
>>stdout.log
>>::::::::::::::
>>Bootstrap: Starting service
>>TomcatStarter: Done
>>TomcatStarter: Done
>>    
>>
>
>  
>


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


Re: JK2 module for AOLserver

Posted by Costin Manolache <cm...@yahoo.com>.
Alexander Leyke wrote:

>>The JNI channel is special because it is single-threaded ( a doors channel
>>will use the same type of code ), and that has some implications in
>>how the request is processed - but the data encoding is the same.
>>  
>>
> Does it mean that in-process worker is a performance bottleneck in
> single-process server?

It seems we have a communication problem :-) - again I don't understand
what you are reffering to.

In jk1, the JNI worker had some performance problems - because it created
a lot of strings and made many (expensive) JNI calls. The ajp
and socket was optimized, but the JNI was not ( it would have required a lot 
of C code ).

In jk2, all those strings are eliminated ( from C side ), we also eliminate
the buffer allocation ( we reuse the same jbyteArray and C array, with
code to eventually support NIO - that cuts 2 memcpy and few other small
things ). We also reduce the number of JNI calls to a minimum ( or almost ).

Regarding the single-threaded behavior - I think this is a major benefit
for JNI ( or doors ) workers, since it can avoid thread switching and a lot
of synchronization. In all other protocol there are 2 threads sending data
to each other. This won't be visible for a small number of RPS, but 
I expect it to be important for very high loads. Well - most likely this
is just a benchmarking exercise - if the servlets are doing anything usefull
they'll dominate the execution time anyway, the connector overhead is 
already extremely small.


>>The JNI worker is working for IIS and Apache2, I see no reason why it
>>won't work with AOLserver. ( I suppose you're aware of the jk1 AOLserver
>>connector - it also used JNI, so you shouldn't have any major problems )
>>
> I am aware of nstomcat module which works with Tomcat 3, but not Tomcat
> 4. There is  nothing of that nature  under
> jakarta-tomcat-connectors-4.1.12-src/jk/native. Should I look better?

You just need to port the nstomcat module to jk2. 

jk1 doesn't support tomcat4 in-process, jk2 does. From the connector
point of view it doesn't matter what tomcat is run ( at one point
it even detected the tomcat version at runtime - all it cares is to
have coyote/jk2 available and have a class with main() ).


>>Just get the socket to work ( it's easier to debug the server-specific
>>code), then enable the jni channel and worker.
>>  
>>
> OK, as I am working on it, there are some Java errors from Tomcat
> startup within AOLserver. I can repeat those errors when running
> TomcatStarter class from shell command line.

Did you get the connector to work with sockets ? ( i.e tomcat out
of process ) ? That's the first step, you need this to work well
to test the aol-specific code. 

Nacho and Mladen are using the JNI code the most, but I suspect
with a different version of tomcat.

You can configure a different starter ( TomcatStarter did work 
with an older version of BootstrapService - now you can't use
the 4.1 version of BS without daemon ). You can probably try
to just configure it to use o.a.catalina.startup.Bootstrap.
( or a different starter with a main() )


Costin


> 
> ::::::::::::::
> stderr.log
> ::::::::::::::
> TomcatStarter: main()
> Try  org.apache.tomcat.startup.Main
> Try  org.apache.catalina.startup.BootstrapService
> Starting org.apache.catalina.startup.BootstrapService
> java.lang.NullPointerException
>         at
> 
org.apache.catalina.startup.BootstrapService.start(BootstrapService.java:244)
>         at
> 
org.apache.catalina.startup.BootstrapService.main(BootstrapService.java:307)
>         at java.lang.reflect.Method.invoke(Native Method)
>         at org.apache.jk.apr.TomcatStarter.run(TomcatStarter.java:127)
>         at java.lang.Thread.run(Thread.java:484)
> Created catalinaLoader in: /<deleted -
> AL>/jakarta-tomcat-4.1.12/server/lib
> [INFO] Registry - -Loading registry information
> [INFO] Registry - -Creating new Registry instance
> [INFO] Registry - -Creating MBeanServer
> [INFO] Http11Protocol - -Initializing Coyote HTTP/1.1 on port 8089
> java.lang.ArrayIndexOutOfBoundsException
>         at
> 
org.apache.catalina.startup.BootstrapService.main(BootstrapService.java:305)
>         at java.lang.reflect.Method.invoke(Native Method)
>         at org.apache.jk.apr.TomcatStarter.run(TomcatStarter.java:127)
>         at java.lang.Thread.run(Thread.java:484)
> java.lang.ArrayIndexOutOfBoundsException
>         at org.apache.jk.apr.TomcatStarter.run(TomcatStarter.java:131)
>         at java.lang.Thread.run(Thread.java:484)
> ::::::::::::::
> stdout.log
> ::::::::::::::
> Bootstrap: Starting service
> TomcatStarter: Done
> TomcatStarter: Done




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


Re: JK2 module for AOLserver

Posted by Alexander Leyke <al...@cs.com>.
Thanks for the reply, Costin. There are some more questions below.

Costin Manolache wrote:

>Ajp13 protocol ( marshalling, etc ) is used for in-process communication
>and out of process communication. By marshalling the data we avoid some
>expensive and complex JNI operations, and benefit of all optimizations 
>done on java side ( and the code is simpler ).
>
>The worker_jni code is just used to start tomcat in-process, but not
>for request forwarding. 
>
>The JNI channel is special because it is single-threaded ( a doors channel
>will use the same type of code ), and that has some implications in
>how the request is processed - but the data encoding is the same.
>  
>
Does it mean that in-process worker is a performance bottleneck in 
single-process server?

>The JNI worker is working for IIS and Apache2, I see no reason why it won't 
>work with AOLserver. ( I suppose you're aware of the jk1 AOLserver connector 
>- it also used JNI, so you shouldn't have any major problems )
>
I am aware of nstomcat module which works with Tomcat 3, but not Tomcat 
4. There is  nothing of that nature  under 
jakarta-tomcat-connectors-4.1.12-src/jk/native. Should I look better?

>
>Just get the socket to work ( it's easier to debug the server-specific 
>code), then enable the jni channel and worker.
>  
>
OK, as I am working on it, there are some Java errors from Tomcat 
startup within AOLserver. I can repeat those errors when running 
TomcatStarter class from shell command line.

::::::::::::::
stderr.log
::::::::::::::
TomcatStarter: main()
Try  org.apache.tomcat.startup.Main
Try  org.apache.catalina.startup.BootstrapService
Starting org.apache.catalina.startup.BootstrapService
java.lang.NullPointerException
        at 
org.apache.catalina.startup.BootstrapService.start(BootstrapService.java:244)
        at 
org.apache.catalina.startup.BootstrapService.main(BootstrapService.java:307)
        at java.lang.reflect.Method.invoke(Native Method)
        at org.apache.jk.apr.TomcatStarter.run(TomcatStarter.java:127)
        at java.lang.Thread.run(Thread.java:484)
Created catalinaLoader in: /<deleted - AL>/jakarta-tomcat-4.1.12/server/lib
[INFO] Registry - -Loading registry information
[INFO] Registry - -Creating new Registry instance
[INFO] Registry - -Creating MBeanServer
[INFO] Http11Protocol - -Initializing Coyote HTTP/1.1 on port 8089
java.lang.ArrayIndexOutOfBoundsException
        at 
org.apache.catalina.startup.BootstrapService.main(BootstrapService.java:305)
        at java.lang.reflect.Method.invoke(Native Method)
        at org.apache.jk.apr.TomcatStarter.run(TomcatStarter.java:127)
        at java.lang.Thread.run(Thread.java:484)
java.lang.ArrayIndexOutOfBoundsException
        at org.apache.jk.apr.TomcatStarter.run(TomcatStarter.java:131)
        at java.lang.Thread.run(Thread.java:484)
::::::::::::::
stdout.log
::::::::::::::
Bootstrap: Starting service
TomcatStarter: Done
TomcatStarter: Done

Your help is always appreciated,
Alex


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


Re: JK2 module for AOLserver

Posted by Costin Manolache <cm...@yahoo.com>.
Alexander Leyke wrote:

> Costin Manolache wrote:
> 
>>In jk2 we use ajp13 for all channels, including JNI. That allows us to
>>reuse the buffers and avoid object allocations from C - which improves a
>>lot the performance of the code ( we also avoid a lot of expensive calls,
>>etc ). Same technique is also used (AFAIK) in mozilla bridge.
>>
>>  
>>
> Do you mean "ajp13" channel would work with in-process worker?

Ajp13 protocol ( marshalling, etc ) is used for in-process communication
and out of process communication. By marshalling the data we avoid some
expensive and complex JNI operations, and benefit of all optimizations 
done on java side ( and the code is simpler ).

The worker_jni code is just used to start tomcat in-process, but not
for request forwarding. 

The JNI channel is special because it is single-threaded ( a doors channel
will use the same type of code ), and that has some implications in
how the request is processed - but the data encoding is the same.

> Let me rephrase my initial question. I am interested in Tomcat executing
> in-process. If JNI worker cannot be used, what alternative do I have to
> run Tomcat in-process? Is JNI worker permanently out or will be
> re-enabled in the future (what's the timetable?)

The JNI worker is working for IIS and Apache2, I see no reason why it won't 
work with AOLserver. ( I suppose you're aware of the jk1 AOLserver connector 
- it also used JNI, so you shouldn't have any major problems )

Just get the socket to work ( it's easier to debug the server-specific 
code), then enable the jni channel and worker.


> In case I am out-of luck with in-process Tomcat <g>, what is the highest
> performance alternative for a Web server to talk to Tomcat 4?

You could use unix channel. Or ( if on solaris ) implement a doors channel
( most of the tricks for making it work are already done for JNI - i.e.
single threaded communication ).

Costin



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


Re: JK2 module for AOLserver

Posted by Alexander Leyke <al...@cs.com>.
Costin Manolache wrote:

>In jk2 we use ajp13 for all channels, including JNI. That allows us to reuse
>the buffers and avoid object allocations from C - which improves a lot the 
>performance of the code ( we also avoid a lot of expensive calls, etc ).
>Same technique is also used (AFAIK) in mozilla bridge.
>
>  
>
Do you mean "ajp13" channel would work with in-process worker?

>>Is JNI worker intentionally disabled, or am I misinterpreting the code?
>>I could fix jk2_jni_worker_service function with some guidance, but is
>>there a similar implementation gap in Tomcat 4 Java classes?
>>    
>>
>
>Yes, the jni worker shouldn't be used.
>
>  
>
Let me rephrase my initial question. I am interested in Tomcat executing 
in-process. If JNI worker cannot be used, what alternative do I have to 
run Tomcat in-process? Is JNI worker permanently out or will be 
re-enabled in the future (what's the timetable?)

In case I am out-of luck with in-process Tomcat <g>, what is the highest 
performance alternative for a Web server to talk to Tomcat 4?

Thanks for your help!
Alex


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


Re: JK2 module for AOLserver

Posted by Costin Manolache <cm...@yahoo.com>.
Alexander Leyke wrote:


> "ajp13" worker factory seems to be hardcoded regardless of actual worker
> type. Here is a snippet from JTC-4.1.12/jk/native2/common/jk_workerEnv.c:

The reason is simple. 

There are 2 "interfaces": protocol and channel. In jk1, the JNI used its own 
protocol ( using String[], etc ). This creates 2 problems: 
- the jni code was harder to maintain
- it was actually slower - since most optimization went into the most used
code, and the Strings and all GC created big problems.

In jk2 we use ajp13 for all channels, including JNI. That allows us to reuse
the buffers and avoid object allocations from C - which improves a lot the 
performance of the code ( we also avoid a lot of expensive calls, etc ).
Same technique is also used (AFAIK) in mozilla bridge.



> I changed the code above to use "ajp13" or "worker.jni" depending on
> ch->mbean->localName , but that still didn't help, because
> jk2_jni_worker_service function in
> JTC-4.1.12/jk/native2/common/jk_worker_jni.c is a placeholder. I did
> make sure not to use default "lb" worker for JNI.

I'll check - worker_jni should be deprecated/removed, you should use 
the channel.

Also note that it is a good idea to use the 'lb' worker - even if you
use a single process, the overhead is very small and it will allow you to
add load balancing easier.



> Is JNI worker intentionally disabled, or am I misinterpreting the code?
> I could fix jk2_jni_worker_service function with some guidance, but is
> there a similar implementation gap in Tomcat 4 Java classes?

Yes, the jni worker shouldn't be used.


> 2) JTC build doesn't seem to be very friendly for non-GNU compilers. I
> use Sun Workshop, and had to write some hacks to make ant and libtool
> work with Sun's C compiler. In particular, both ant and libtool insisted
> on supplying invalid "-W" command option to compiler. I suspect that
> JTC-4.1.12/jk/jkant/java/org/apache/jk/ant/compilers/CcCompiler.java is
> intended for UCB cc support, and I need to write a separate class for
> ant to work with Sun's cc and bypass libtool (which configured itself
> mostly correctly to use Sun cc, but still insisted on "-W"). Had anyone
> had any relevant experience?

There is a target that allows use of ant-contrib's cpp tasks. 
IMHO we should deprecate jkant and switch to ant-contrib, at the moment 
they support far more compilers and seem to have an active community.

You can submit a patch to CcCompiler if you want, but I think it would be
better if you could help test ( and improve ) the cc tasks. ( AFAIK sun 
compiler is supported ).

Costin 




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