ctx = new InitialContext(p);
home = (RemoteShellHome) ctx.lookup("ShellSession");
shell = home.create(true);
shell2 = home.create(shell.getSessionID(), true);
ShellObjectReader sor = new ShellObjectReader(shell2, "0");
String bsize = System.getProperty("org.jboss.fresh.parsek.cp2.client.bufSize");
if (bsize != null) {
try {
bsizei = Integer.parseInt(bsize);
} catch (NumberFormatException ex) {
}
}
sor.setBufferSize(bsizei);
in = new BufferedInputStream(new ShellConsoleInputStream(sor));
Thread t = new Thread() {
public void run() {
byte[] buf = new byte[512];
try {
while (true) {
int rc = in.read(buf, 0, buf.length);
while (rc != -1) {
try {
// log.debug(">>>> read");
//System.out.write(buf, 0, rc);
rc = in.read(buf, 0, buf.length);
// log.debug("<<<< read");
} catch (ShellIOException ex) {
Throwable th = ex;
log.debug("EXCEPTION: ", th);
/*
while(th instanceof ShellIOException) {
th=((ShellIOException)th).getRootThrowable();
if(th!=null) {
log.debug("Caused By: ");
th.printStackTrace();
}
}
while(th instanceof ApplicationIOException) {
th=((ApplicationIOException)th).getRootThrowable();
if(th!=null) {
log.debug("Caused By: ");
th.printStackTrace();
}
}
*/
break;
// log.debug("An application exception has occured: ");
// ex.getRootThrowable().printStackTrace();
// } catch(EOFException ex) {
// break;
} catch (Exception ex) {
//ex.printStackTrace();
log.debug("EXCEPTION from shell-stdin: ", ex);
break;
}
}
// log.debug("Reinitialized input from remote...");
ShellObjectReader sor = new ShellObjectReader(shell2, "0");
sor.setBufferSize(bsizei);
in = new BufferedInputStream(new ShellConsoleInputStream(sor));
}
} catch (Throwable ex) {
//ex.printStackTrace();
log.debug("EXCEPTION from shell-stdin: ", ex);