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

Posted By:   Emilio_SANCHEZ
Posted On:   Monday, March 11, 2002 08:05 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!)!!!!

Could someone help me.

Thanks a lot.
   <<Less

Re: I try to launch a RMI Server within a pthread from a JNI C++ program

Posted By:   Alexander_Krapf  
Posted On:   Thursday, March 14, 2002 02:49 PM

Emilio,


if you were on Windows, Solaris, or Linux, I would tell you to try out our JunC++ion tool which generates C++ proxy classes for Java classes.


Do you need this working on AIX and how quickly?


JunC++ion works around many issues that might take you weeks each to figure out. I can't guarantee that it would work in this specific usecase because I've never tried to solve this specific problem myself, but I would be surprised if it didn't. Can you try it out on Windows or Solaris?


You can find out more at www.codemesh.com.


Good luck,


Alex

About | Sitemap | Contact