dcsimg
I try to launch a RMI Server within a pthread from a JNI C++ program
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Emilio_SANCHEZ
Posted On:   Monday, March 11, 2002 07:53 AM

My purpose is to launch a RMI server from a JNI C++ program. As the RMI Server main method has "Naming.Rebind" calls it never returns which is normal. So I had to start the main java method within a pthread (in a AIX platform) to return back: Here is the JNI call which seems to work fine in the beginning void * go() { JNIEnv *env; JavaVMAttachArgs args; jmethodID id_main = 0; args.version = JNI_VERSION_1_2; args.name = NULL; args.group = NULL; jvm -> AttachCurrentThread((void**)&env, &args); class_Server = (env)->FindClass("ICdcLmc"); id_main   More>>


My purpose is to launch a RMI server
from a JNI C++ program.
As the RMI Server main method has "Naming.Rebind" calls it never returns which is normal.
So I had to start the main java method
within a pthread (in a AIX platform) to return back:

Here is the JNI call which seems to work fine in the beginning




void * go()
			
{
JNIEnv *env;
JavaVMAttachArgs args;
jmethodID id_main = 0;

args.version = JNI_VERSION_1_2;
args.name = NULL;
args.group = NULL;

jvm -> AttachCurrentThread((void**)&env, &args);


class_Server = (env)->FindClass("ICdcLmc");


id_main = (env)->GetStaticMethodID(class_Server, "initServ", "([Ljava/lang/String;)V");


(env)->CallStaticVoidMethod(class_Serveur, id_main, NULL);

jvm -> DetachCurrentThread();

}






This method is called as followed :

			
pthread_t th;
status = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
pthread_create(&th, NULL, go, NULL);
sleep(1000);



The main JAVA method is successfully reached but it hangs when a RMI stub object is binded in the RMI registry:
			
_serverConception = new CapCServerConception();


The ClassLoader doesn't find the Stub :
java.lang.ClassNotFoundException: CapServeur/CapConception/CapCServeurConception_Stub (no security manager: RMI class loader disabled).

The very curious thing is that I haven't any problem when I create the jvm within the pthread method "go" (and so don't have to attach the jvm to the current thread!)!!!!


Can someone help me ?

Thanks.
   <<Less
About | Sitemap | Contact