This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Call from native thread is not handled by context class loader   Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Call from native thread is not handled by context class loader   " Watch "Call from native thread is not handled by context class loader   " New topic
Author

Call from native thread is not handled by context class loader

lavanya mishra
Greenhorn

Joined: Aug 24, 2010
Posts: 1
Hello. I have scenario like this:
Call from JAVA->c++ >JAVA

When I call JAVA defined oeprations (kind of call back) from C++ app(called by java) immediately after receiving the call from JAVA, it works fine.

C++ call from JAVA initiates a chain/ stack of subsequent calls (which may spawn a new process/ thread), and finally a call is again made from last spwned process/ thread to JAVA. When we call findClass on env. after attaching current thread to JVM, env is not able to find the class.

As per my understanding this is probably because when we call from native thread to JAVA, it is using system class loader to load the class. And system is not able to find that class, as it is not in classpath probably. This is fine.

In my JAVA application I have used custom class loader to load all my appliction classes. And this is capable of loading class which is actually required when findClass is called.

How to instruct the env/ jvm to find class using my custom class loader, instead of system class loader.

I dont want to use system class loader at all.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Call from native thread is not handled by context class loader
 
Similar Threads
JVM Crash within native method
Class Loading Question
64-bit JNI C++ to JAVA invocation multiple threads classloader problem
A JNI Question
Specifying which ClassLoader gets used by FindClass()