}
private void reinitShell() throws NamingException, ShellException {
if (shell == null) {
InitialContext ctx = null;
SystemShell sysshell;
String sslookup = SYSTEM_SHELL_JNDI;
try {
ctx = new InitialContext();
Context env = (Context) ctx.lookup("java:comp/env");
sslookup = (String) env.lookup("SystemShellJNDI");
} catch (NameNotFoundException ex) {
log.info("SystemShellJNDI ENV not set. Using defaults.");
} finally {
if (ctx != null) {
try {
ctx.close();
} catch (Exception e) {
log.error("Could not close " + ctx + '!', e);
}
}
}
try {
sysshell = (SystemShell) new RegistryContext().lookup(sslookup);
// } catch(NameNotFoundException ex) {
// ex.printStackTrace();
// throw new RuntimeException(ex.getMessage());
} catch (NamingException ex) {
log.error("Error while reiniting shell!", ex);
throw new RuntimeException(ex);
}
if (sessid == null) {
shell = sysshell.startSession(uctx, interactive);
sessid = shell.getSessionID();
} else {
shell = sysshell.continueSession(sessid);
}
if (shell == null) {
throw new org.jboss.fresh.shell.SessionTimeoutException("Shell session has timed out.");
}
}