mod_jk inprocess worker and Apache 2.0 not working

2001-12-04 Thread GAWLAS,JULIUS (HP-Cupertino,ex1)

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:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: mod_jk inprocess worker and Apache 2.0 not working

2001-12-04 Thread costinm

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:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: mod_jk inprocess worker and Apache 2.0 not working

2001-12-04 Thread GAWLAS,JULIUS (HP-Cupertino,ex1)

Costin,

 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 ).

Thanks for quick answer, but I don't think I can quite see 
contradiction here - I would appreciate very much if you can 
expand on the explanation. 

BTW, few days ago I posted a patch to t-j-c mod_jk.c for Apache 2.0. 
Most important is the change in prototype of jk_post_config 
which used to be void but now needs to return success code, 
also changes to types of some variables to better confirm to 
Apache 2.0 types. I am attaching it again since as it stands now mod_jk
does not work with Apache 2.0.

Thanks again
Julius


Index: mod_jk.c
===
RCS file:
/home/cvspublic/jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.c,v
retrieving revision 1.37
diff -u -r1.37 mod_jk.c
--- mod_jk.c2001/11/21 00:09:21 1.37
+++ mod_jk.c2001/11/30 23:58:13
@@ -110,9 +110,8 @@
 #define ADD_SSL_INFO
 
 /* module MODULE_VAR_EXPORT jk_module; */
-AP_DECLARE_DATA module jk_module;
+AP_MODULE_DECLARE_DATA module jk_module;
 
-
 typedef struct {
 
 /*
@@ -326,7 +325,7 @@
 
 /* Debug - try to get around rwrite */
 while( ll  0 ) {
-long toSend=(llCHUNK_SIZE) ? CHUNK_SIZE : ll;
+size_t toSend=(llCHUNK_SIZE) ? CHUNK_SIZE : ll;
 r = ap_rwrite((const char *)bb, toSend, p-r );
 jk_log(main_log, JK_LOG_DEBUG, 
writing %ld (%ld) out of %ld \n,toSend, r, ll );
@@ -535,7 +534,7 @@
 }
 
 if(conf-envvars_in_use) {
-apr_array_header_t *t = apr_table_elts(conf-envvars);
+const apr_array_header_t *t = apr_table_elts(conf-envvars);
 if(t  t-nelts) {
 int i;
 apr_table_entry_t *elts = (apr_table_entry_t *)t-elts;
@@ -563,7 +562,7 @@
 s-num_headers  = 0;
 if(r-headers_in  apr_table_elts(r-headers_in)) {
 int need_content_length_header = (!s-is_chunked 
s-content_length == 0) ? JK_TRUE : JK_FALSE;
-apr_array_header_t *t = apr_table_elts(r-headers_in);
+const apr_array_header_t *t = apr_table_elts(r-headers_in);
 if(t  t-nelts) {
 int i;
 apr_table_entry_t *elts = (apr_table_entry_t *)t-elts;
@@ -1514,7 +1513,7 @@
 return;
 }
 
-static void jk_post_config(apr_pool_t *pconf, 
+static int jk_post_config(apr_pool_t *pconf, 
apr_pool_t *plog, 
apr_pool_t *ptemp, 
server_rec *s)
@@ -1528,6 +1527,7 @@
 init_jk( pconf, conf, s );
 }
 }
+   return OK;
 }
 
 /** Use the internal mod_jk mappings to find if this is a request for

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: mod_jk inprocess worker and Apache 2.0 not working

2001-12-04 Thread costinm

Hi Julius,

Thanks for the patch - I've already added it to jk2. I did the rollback on
jk ( removing all jk_env, jk_registry, adding back ajp12 ), now
the 'main' tree should have the stable jk.

Sorry for the delay.

  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 ).

 Thanks for quick answer, but I don't think I can quite see
 contradiction here - I would appreciate very much if you can
 expand on the explanation.

Apache has several (unix) processes. A request can go to either of
them for processing.

With JNI, each apache process will have it's own VM and will process
requests. If a session is created, it'll be in one of the VMs,
and the servlet spec requires that all further requets within that
session go to the same VM.

This is not possible right now - a second request can be received
by another process/VM and jniworker can't forward it right now.

We have most of the code ( in lb_worker ), but we need to enable it.

Costin


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: mod_jk inprocess worker and Apache 2.0 not working

2001-12-04 Thread GAWLAS,JULIUS (HP-Cupertino,ex1)

Costin,

 With JNI, each apache process will have it's own VM and will process
 requests. If a session is created, it'll be in one of the VMs,
 and the servlet spec requires that all further requets within that
 session go to the same VM.
 
 This is not possible right now - a second request can be received
 by another process/VM and jniworker can't forward it right now.

Ahhh, of course - I guess I was not really connecting correctly, was
not thinking about that; thanks for explanations.
 
 We have most of the code ( in lb_worker ), but we need to enable it.

cool, looking forward to seeing it

Julius

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]