Pages

Monday, April 2, 2012

Hacking the JVM inside WebSphere Application Server


Sometimes there arise situations where certain JVM classes inside WebSphere Application Server like java.lang.Thread or java.util.Timer need to be instrumented to add some debug information. In such scnearios locate the src.zip file under WAS_HOME/java/src.zip. This file contains all the JDK source code. Extract the file you want to the eclipse workspace and make the necessary modifications like calling Thread.dumpStack() etc.,

Thereafter package the modified class file in its own jar say patch.jar and add the following property to the JVM generic argument
-Xbootclasspath/p:<FULLY_QUALIFIED_PATH_TO_JAR>


Note that the "/p" is important.  The bootclasspath is where the JDK loads "core" classes from, and the "/p" says to prepend the value you are supplying, thereby overriding the default location of the core classes.

Alternately


You can  configure the following WAS JVM generic argument to print  the stacktrace when a thread is started or stopped...
-Xdump:console:events=thrstart+thrstop

Sample output

JVMDUMP006I Processing Dump Event "thrstart", detail "" - Please Wait.
-------- Console dump --------


Stack Traces of Threads:


ThreadName=Signal Dispatcher(0805BFFC)
Status=Running


ThreadName=main(0805B5FC)
Status=Waiting
Monitor=0805ADE0 (Thread public flags mutex)
Count=0
Owner=(00000000)
        In com/ibm/oti/vm/BootstrapClassLoader.loadClass(Ljava/lang/String;)Ljava/lang/Class;
        In com/ibm/misc/SystemIntialization.lastChanceHook()V
        In java/lang/System.completeInitialization()V
        In java/lang/Thread.(Ljava/lang/String;Ljava/lang/Object;IZ)V


^^^^^^^^ Console dump ^^^^^^^^
JVMDUMP013I Processed Dump Event "thrstart", detail "".

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.