Original report by Anonymous.
Original issue 99 created by christophe.cornu on 2014-07-02T13:50:42.000Z:
What steps will reproduce the problem?
- Get the latest (e.g. r93), package it into a JavaWebStart app
- Run JavaWebStart app
- Java console logs many ClassNotFoundException coming from CEF callbacks in particular:
java.lang.NoClassDefFoundError: org/cef/network/CefRequest_N
Caused by: java.lang.ClassNotFoundException: org.cef.network.CefRequest_N
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
What is the expected output? What do you see instead?
No stack trace and things work fine.
What version of the product are you using? On what operating system?
Latest JCEF r93, Windows 7, Java 1.7 64 bit
Please provide any additional information below.
This appears to be a side effect of how env->FindClass works under JavaWebStart. E.g. in request_handler.cpp, CEF callbacks execute the following.
jobject jrequest = NewJNIObject(env, "org/cef/network/CefRequest_N");
This invokes env->FindClass.
But under JavaWebStart, this thread uses a classloader that doesn't have access to the jar's of the JavaWebStart app. It can find classes such as java.* packages but not our own org.cef.* classes.
This doesn't affect threads that come from Java e.g. CefCookieManager_N.cpp JNIEXPORT jobject JNICALL Java_org_cef_network_CefCookieManager_1N_N_1GetGlobalManager
(JNIEnv *env, jclass cls) is fine because it's called from Java and uses a different classloader.
Here are some links that describe this javawebstart behavior.
https://community.oracle.com/thread/1307947?start=0&tstart=0
http://forums.netbeans.org/ptopic8237.html
http://stackoverflow.com/questions/20851342/using-qt-c-to-call-java-code-through-jni-findclass-does-not-find-class
I'm reporting this to give a heads-up about this special behavior. I'm looking into a workaround, probably by creating global references to the class'es from Java_org_cef_CefApp_N_1Initialize. Then CEF callbacks could use these global references instead of relying on env->FindClass.
Again the interesting part is that it does not affect all JNI calls, just CEF callbacks that don't come from Java.
Original report by Anonymous.
Original issue 99 created by christophe.cornu on 2014-07-02T13:50:42.000Z:
What steps will reproduce the problem?
java.lang.NoClassDefFoundError: org/cef/network/CefRequest_N
Caused by: java.lang.ClassNotFoundException: org.cef.network.CefRequest_N
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
What is the expected output? What do you see instead?
No stack trace and things work fine.
What version of the product are you using? On what operating system?
Latest JCEF r93, Windows 7, Java 1.7 64 bit
Please provide any additional information below.
This appears to be a side effect of how env->FindClass works under JavaWebStart. E.g. in request_handler.cpp, CEF callbacks execute the following.
jobject jrequest = NewJNIObject(env, "org/cef/network/CefRequest_N");
This invokes env->FindClass.
But under JavaWebStart, this thread uses a classloader that doesn't have access to the jar's of the JavaWebStart app. It can find classes such as java.* packages but not our own org.cef.* classes.
This doesn't affect threads that come from Java e.g. CefCookieManager_N.cpp JNIEXPORT jobject JNICALL Java_org_cef_network_CefCookieManager_1N_N_1GetGlobalManager
(JNIEnv *env, jclass cls) is fine because it's called from Java and uses a different classloader.
Here are some links that describe this javawebstart behavior.
https://community.oracle.com/thread/1307947?start=0&tstart=0
http://forums.netbeans.org/ptopic8237.html
http://stackoverflow.com/questions/20851342/using-qt-c-to-call-java-code-through-jni-findclass-does-not-find-class
I'm reporting this to give a heads-up about this special behavior. I'm looking into a workaround, probably by creating global references to the class'es from Java_org_cef_CefApp_N_1Initialize. Then CEF callbacks could use these global references instead of relying on env->FindClass.
Again the interesting part is that it does not affect all JNI calls, just CEF callbacks that don't come from Java.