转自:http://bbs.weblogicfans.net/redirect.php?tid=237&goto=lastpost
?
1、weblogic816
C:\Documents and Settings\tony>java -cp E:\bea816\weblogic81\server\lib\weblogic.jar weblogic.Admin?-url localhost:7001 -username weblogic -password weblogic THREAD_DUMP?
Thread Dump has been printed to the servers standard out (by default, the shell?
in which the server is running).?
可以看到打印成功!?
但是在9版本并不能使用该方法
2、weblogic923
启动server,打开wlst.cmd
连接到启动的AdminServer
Connect(‘weblogic’,’weblogic’,’t3://127.0.0.1:7001’)
threadDump()
可以看到写到了一个叫Thread_Dump_AdminServer.txt的文件里(该文件存在wlst.cmd这个脚本同样的目录里,如E:\bea\weblogic92\common\bin\)。
再次运行threadDump(),将会覆盖该文件。
因为目前是只启动了一个server,所以在进行dump的时候并没指定server,默认就对admin做了dump.
再启动一个server1.现在再次用不指定server的threadDump()仍旧只会产生admin的dump.
利用help命令,发现还有一个指定server的dump方法。
threadDump([writeToFile], [fileName], [serverName])
注意里面有个属性是是否写到文件,我这里是true.所以生成了dump文件.
3、weblogic10.0 for solarisx86
在soalris10上(weblogic10.0)操作wlst工具来进行线程堆栈成功。?
wls:/mydomain/serverConfig> threadDump(writeToFile='true', fileName='/opt/bea10/threaddump1.txt')?
......................?
........................?
.......................?
"Reference Handler" waiting for lock java.lang.ref.Reference$[email=Lock@c2bce4]Lock@c2bce4[/email] WAITING?
? ?? ???java.lang.Object.wait(Native Method)?
? ?? ???java.lang.Object.wait(Object.java:474)?
? ?? ???java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)?
"main" waiting for lock [email=weblogic.t3.srvr.T3Srvr@ff2b7c]weblogic.t3.srvr.T3Srvr@ff2b7c[/email] WAITING?
? ?? ???java.lang.Object.wait(Native Method)?
? ?? ???java.lang.Object.wait(Object.java:474)?
? ?? ???weblogic.t3.srvr.T3Srvr.waitForDeath(T3Srvr.java:747)?
? ?? ???weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:396)?
? ?? ???weblogic.Server.main(Server.java:67)?
The Thread Dump for server AdminServer?
has been successfully written to /opt/bea10/threaddump1.txt?
利用py文件来生成thread dump
(1).在已经进入了wlst的环境下?
wls:/testDomain/serverConfig> execfile('/opt/bea10/user_projects/domains/testDomain/bin/threaddumpadmin.py')?
Connecting to?t3://192.168.0.55:7001?with userid weblogic ...?
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'testDomain'.?
Warning: An insecure protocol was used to connect to the?
server. To ensure on-the-wire security, the SSL port or?
Admin port should be used instead.?
Thread dump for the running server: AdminServer?
"[ACTIVE] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'" RUNNABLE?
? ?? ???sun.management.ThreadImpl.getThreadInfo0(Native Method)?
? ?? ???sun.management.ThreadImpl.getThreadInfo(ThreadImpl.java:142)?
? ?? ???weblogic.platform.VM15.threadDumpAsString(VM15.java:22)?
....................?
The Thread Dump for server AdminServer?
has been successfully written to /opt/bea10/threaddump2.txt?
Exiting?WebLogic?Scripting Tool.?
(2).没有进入wlst的情况?
-bash-3.00# java -cp /opt/bea10/wlserver_10.0/server/lib/weblogic.jar weblogic.WLST threaddumpadmin.py?
Initializing WebLogic Scripting Tool (WLST) ...?
Welcome to WebLogic Server Administration Scripting Shell?
Type help() for help on available commands?
Connecting to?t3://192.168.0.55:7001?with userid weblogic ...?
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'testDomain'.?
Warning: An insecure protocol was used to connect to the?
server. To ensure on-the-wire security, the SSL port or?
Admin port should be used instead.?
Thread dump for the running server: AdminServer?
"[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'" waiting for lock [email=weblogic.work.ExecuteThread@18a290f]weblogic.work.ExecuteThread@18a290f[/email] WAITING?
? ?? ???java.lang.Object.wait(Native Method)?
....................?
The Thread Dump for server AdminServer?
has been successfully written to /opt/bea10/threaddump2.txt?
Exiting WebLogic Scripting Tool.?
下面是 threaddumpadmin.py的内容:?
connect('weblogic','weblogic','t3://192.168.0.55:7001')?
threadDump(writeToFile='true', fileName='/opt/bea10/threaddump3.txt')?
exit()
?
?
?
?
?
注:
WLS816利用weblogic.Admin生成thread_dump,仅支持的SUN与JRockit,因为它是使用bea提供的native jvm hook生成的,对于HP或IBM的JDK它是不支持的。
进行thread dump,在unix环境下,最保险的办法是kill -3。因为无论是weblogic.Admin还是wslt,它都是在目标jvm之外的,如果碰到一些特别的场景,如线程耗尽那些,可能这些命令不能正常工作。