tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shimon Crown <>
Subject Re: REPOST (+more comments) - Classloading problems with JNI
Date Sun, 11 Aug 2002 05:20:41 GMT
Thanks Michael while this is not the solution it does give me some clues as
to where to look.

Looking at my over two year old JNI code I see that I do pass a reference to
the JVM as initialization parameter to the C++ code.

In order to find the classes for the callback I do the following

 JNIEnv* env;
 m_jvm->GetEnv(reinterpret_cast<void**>(&env),JNI_VERSION_1_2); // m_jvm is
the cached JVM

Clearly the Java environment I am getting is not the one I thought it was.
And I thought DLL hell was a problem !


> I've done no work with JNI, but have read a little on it.
> My understanding is that when making calls from native
> to java, the native code often instantiates a new JVM. If
> your are doing this then I would suspect that this is your problem.
> Your newly instantied JVM would not have access to the classes
> loaded in the Tomcat JVM instance. Even if you included these in
> your CLASSPATH (as you mentioned with Jetty) then you'd be
> accessing java classes in a JVM seperate from the one that Tomcat
> is using (which is not what I think you want to do).
> It seems that you'd somehow need to, first make a java->C++ call
> to your native code to give it a handle to the Tomcat JVM instance,
> and from there use this handle in your native code to access or invoke
> the java classes/objects that you so desire.
> Michael LeValle

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message