Friday, March 20, 2009

Thread Dumps and WLST

you can read WLST output into a String, so instead of into a file you can redirect some commands into a String:

String connect = "connect('weblogic', 'weblogic', 't3://bcdev07:5210')";
WLST.ensureInterpreter();

WLSTInterpreter interpreter = WLST.getWLSTInterpreter();
interpreter.exec(connect);
while (true) {
OutputStream os = new ByteArrayOutputStream();
interpreter.setOut(os);
interpreter.exec("threadDump('false')");
System.out.println("buffer="  + os.toString());
TestingUtilities.sleep(100);
}





2 comments:

Antonio De Juan said...

Hi a little question, have ou tried using pwd()command?, I have tested a big list of commands but thar doesn' work, if you have a way or advice would be great.

thanks in advance.

vernetto said...

try this:

WLSTInterpreter interpreter = WLST.getWLSTInterpreter();
interpreter.exec(connect);
interpreter.exec("serverRuntime()\n");
while (true) {
OutputStream os = new ByteArrayOutputStream();
interpreter.setOut(os);

interpreter.exec("myvar=pwd()");
interpreter.exec("print myvar");

System.out.println("buffer=" + os.toString());
Thread.sleep(1000);
}