Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

JNI->FindClass, NoClassDefFoundError!

User_TASERAug 14 2021 — edited Aug 14 2021

Hi,

I encountered a problem when use jni_env->FindClass(...) to lookup my own class, below is my situation:
Recently I want to intercept all exception event for the web project in tomcat, so I write an exception handler (com.me.JVMTIExceptionHandler) and a shared library (libExceptCatch.so, call the exception handle method in JVMTIExceptionHandler class), in jsp write a clause to generate an NullException (index.jsp).
When start tomcat, add the jvm parameters -agentpath:/home/XXX/libExceptCatch.so, setup the CLASSPATH.
After everything is ok, and when I visit the jsp page, tomcat crashes because in libExceptCatch.so, can't find my com.me.JVMTIExceptionHandler.
I looked up the JNI Reference, say:
'Since JDK 1.2, when FindClass is called through the Invocation Interface, there is no current native method or its associated class loader. In that case, the result of ClassLoader.getSystemClassLoader is used. This is the class loader the virtual machine creates for applications, and is able to locate classes listed in the java.class.path property.'
I've also tried to set -Djava.class.path=..., still not work. Below screenshot is my configuration and codes.
Classpath.PNGjvm configuration.PNG
Error.PNG
JVMTIExceptionHandler.PNGJVMTITest.so.PNGindex.jsp.PNG
Then I write an independent class with main method not placed in tomcat, just start it using java command, it works well. I just learnt JVMTI and JNI recently, completely have no idea about this.
mainclass.PNGmain.PNGsuccess.PNGIn callbackEventException, I add a class name filter because when jvm, there're lots of exception happening, such as fail to load some jars and also can't find my class for the 2nd situation.
load.PNG
Regards,

Comments

Arnoschots-Oracle Apr 22 2020 — edited on Apr 22 2020

Hi,

The "sudo al-config -s" doesn't work on my Autonomous Linux instance.

Command output:

[opc@opsserver ~]$ sudo al-config -s

/sbin/al-config: illegal option -- s

Configure OCI notification service topic OCID:

  Usage:

    al-config -T [topic OCID]

  Options:

    -T [topic OCID] OCI notification service topic OCID

Configure OCI CLI profile:

  Usage:

    al-config -u [user OCID] -t [tenancy OCID] -k [key file]

  Options:

    -u [user OCID] OCI User OCID

    -t [tenancy OCID] OCI Tenancy OCID

    -k [key file] from which we obtaion the API private key

    -p [key passphrase file] from which we obtain API key passphrase. Provide

       this if API private key is encrypted. If not provided, user will be

       prompted to enter passphrase.

1 - 1

Post Details

Added on Aug 14 2021
0 comments
826 views