File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
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://aspose.com/file-tools
 
subject: Call from native thread is not handled by context class loader
 
Similar Threads
A JNI Question
64-bit JNI C++ to JAVA invocation multiple threads classloader problem
JVM Crash within native method
Class Loading Question
Specifying which ClassLoader gets used by FindClass()