if (ic == null) {
JNDIConfigUtil.JndiServerInfo jndiServerInfo = JNDIConfigUtil.getJndiServerInfo(jndiServerName);
if (jndiServerInfo == null) {
throw new GenericConfigException("ERROR: no jndi-server definition was found with the name " + jndiServerName + " in jndiservers.xml");
}
try {
if (UtilValidate.isEmpty(jndiServerInfo.contextProviderUrl)) {
ic = new InitialContext();
} else {
Hashtable<String, Object> h = new Hashtable<String, Object>();
h.put(Context.INITIAL_CONTEXT_FACTORY, jndiServerInfo.initialContextFactory);
h.put(Context.PROVIDER_URL, jndiServerInfo.contextProviderUrl);
if (jndiServerInfo.urlPkgPrefixes != null && jndiServerInfo.urlPkgPrefixes.length() > 0)
h.put(Context.URL_PKG_PREFIXES, jndiServerInfo.urlPkgPrefixes);
if (jndiServerInfo.securityPrincipal != null && jndiServerInfo.securityPrincipal.length() > 0)
h.put(Context.SECURITY_PRINCIPAL, jndiServerInfo.securityPrincipal);
if (jndiServerInfo.securityCredentials != null && jndiServerInfo.securityCredentials.length() > 0)
h.put(Context.SECURITY_CREDENTIALS, jndiServerInfo.securityCredentials);
ic = new InitialContext(h);
}
} catch (Exception e) {
String errorMsg = "Error getting JNDI initial context for server name " + jndiServerName;
Debug.logError(e, errorMsg, module);
throw new GenericConfigException(errorMsg, e);
}
if (ic != null) {
contexts.put(jndiServerName, ic);
}