You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "GAWLAS,JULIUS (HP-Cupertino,ex1)" <ju...@hp.com> on 2001/12/04 18:59:38 UTC

mod_jk inprocess worker and Apache 2.0 not working

I am trying to make inprocess tomcat work with Apache 2.0 without much
success. 

I am using j-t-c mod_jk from cvs. First I noticed that since Apache calls 
module initialization twice jni worker fails when trying to load jvm the 
second time. 

I found in the archives that that issue has been adressed in the mod_jk that

goes along tomcat 3.3 so I took changes to loading JVM and applied them to
j-t-c
jk_jni_worker.c. Now JVM initializes properly but it failes when calling
tomcat 
inside service() method. Maybe there are more changes neccessary to make it
work?

Note that when I temporarly "fix" Apache to avoid double call to
initialization 
all works fine.

Any ideas?

Thanks
Julius

Here is the patch that I applied to j-t-c jk_jni_worker.c

Index: jk_jni_worker.c
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat-connectors/jk/native/common/jk_jni_worker.c,v
retrieving revision 1.6
diff -u -r1.6 jk_jni_worker.c
--- jk_jni_worker.c	2001/11/17 06:00:24	1.6
+++ jk_jni_worker.c	2001/12/04 17:26:50
@@ -751,9 +751,10 @@
                dlerror());
     } else {
         jni_create_java_vm = dlsym(handle, "JNI_CreateJavaVM");
+        jni_get_created_java_vms = dlsym(handle, "JNI_GetCreatedJavaVMs");
         jni_get_default_java_vm_init_args = dlsym(handle,
"JNI_GetDefaultJavaVMInitArgs");
 
-        if(jni_create_java_vm && jni_get_default_java_vm_init_args) {
+        if(jni_create_java_vm && jni_get_default_java_vm_init_args &&
jni_get_created_java_vms) {
     	    jk_log(l, JK_LOG_DEBUG, 
                    "In load_jvm_dll, symbols resolved, done\n");
             return JK_TRUE;
@@ -931,7 +932,7 @@
     int optn = 0, err;
     char* tmp;
 
-    *env = NULL;
+    *env = penv = NULL;
 
     jk_log(l, JK_LOG_DEBUG, 
            "Into open_jvm2\n");
@@ -992,10 +993,25 @@
     }
 
     jk_log(l, JK_LOG_DEBUG, "In open_jvm2, about to create JVM...\n");
+
+    err=jni_create_java_vm(&(p->jvm), &penv, &vm_args);
+
+    if (JNI_EEXIST == err)
+    {
+        int vmCount;
+    	jk_log(l, JK_LOG_DEBUG, "JVM alread instantiated.  Trying to attach
instead.\n"); 
+
+        jni_get_created_java_vms(&(p->jvm), 1, &vmCount);
+        if (NULL != p->jvm)
+            penv = attach_to_jvm(p, l);
 
-    if((err=jni_create_java_vm(&(p->jvm), &penv, &vm_args)) != 0) {
+        if (NULL != penv)
+            err = 0;
+    }
+
+    if(err != 0) {
     	jk_log(l, JK_LOG_EMERG, "Fail-> could not create JVM, code: %d \n",
err); 
-        return JK_FALSE;
+            return JK_FALSE;
     }
     jk_log(l, JK_LOG_DEBUG, "In open_jvm2, JVM created, done\n");

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


Re: mod_jk inprocess worker and Apache 2.0 not working

Posted by co...@covalent.net.
Hi Julius,

> I am trying to make inprocess tomcat work with Apache 2.0 without much
> success.
>
> I am using j-t-c mod_jk from cvs. First I noticed that since Apache calls
> module initialization twice jni worker fails when trying to load jvm the
> second time.

The main problem with JNI and apache is that we can't support sessions
corectly. Apache is a multi-process server ( even apache2.0 - each process
has multiple threads, but it's still multiprocess ).

All other issues ( starting up vm, etc ) are relatively easy to solve.

In jk2 I hope to have the jni worker fixed ( i.e. use 'lb' to migrate the
request to the right server if in a session ).


Costin


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